Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,30 @@ Run `th-cli test-run-execution --id {id}` with a test run execution id to fetch

For JSON respond, add `--json` to the command.

### Test Run Execution Repeat

Run `th-cli test-run-execution repeat --id {id}` to create a new test run execution with
the same selected tests and config as an existing one, then start it and attach to it the
same way `run-tests` does (and the frontend's "Repeat" action does): streaming live test
progress and forwarding any user prompts to this terminal. Use `--title` to override the
generated title (defaults to the original title with an updated timestamp; the backend
always appends a timestamp regardless). As with `run-tests`, `--no-color` disables colored
output and `--no-streaming` disables the real-time web log viewer (enabled by default) for
the new execution.

### Test Run Execution Export

Run `th-cli test-run-execution export --id {id}` to export a test run execution's config
and results to a JSON file. Use `--output-file` to override the default filename
(`<execution-title>-execution.json`).

### Test Run Execution Import

Run `th-cli test-run-execution import --file {file} --project-id {id}` to import a test
run execution previously written by `test-run-execution export` into the given project.
The backend rejects the import if the file's `db_revision` doesn't match the destination
instance's current database revision.

### Project Create

Run `th-cli project create --name {project name} --config {config file}` to create a new project. Project name is required.
Expand Down
50 changes: 50 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,56 @@ def sample_test_run_execution() -> api_models.TestRunExecutionWithChildren:
)


@pytest.fixture
def two_way_talk_test_run_execution() -> api_models.TestRunExecutionWithChildren:
"""Sample test run execution whose selected tests include TC_WEBRTC_1_6, the two-way-talk test."""
return api_models.TestRunExecutionWithChildren(
id=2,
title="Two Way Talk Run",
state=api_models.TestStateEnum.pending,
project_id=1,
test_suite_executions=[
api_models.TestSuiteExecution(
id=2,
execution_index=1,
collection_id="SDK Python Tests",
public_id="Python Testing Suite",
mandatory=False,
state=api_models.TestStateEnum.pending,
test_run_execution_id=2,
test_suite_metadata_id=2,
test_case_executions=[
api_models.TestCaseExecution(
id=2,
execution_index=1,
public_id="TC_WEBRTC_1_6",
state=api_models.TestStateEnum.pending,
test_suite_execution_id=2,
test_case_metadata_id=2,
test_case_metadata=api_models.TestCaseMetadata(
id=2,
public_id="TC_WEBRTC_1_6",
title="Two Way Talk",
description="WebRTC two-way talk test",
version="1.0",
source_hash="webrtc123",
),
test_step_executions=[],
)
],
test_suite_metadata=api_models.TestSuiteMetadata(
id=2,
public_id="Python Testing Suite",
title="Python Testing Suite",
description="Test suite for Python-based testing",
version="1.0",
source_hash="pytesting456",
),
)
],
)


@pytest.fixture
def sample_test_runner_status() -> api_models.TestRunnerStatus:
"""Create a sample test runner status for testing."""
Expand Down
27 changes: 27 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,33 @@ def capture(**kwargs):

assert captured_host[0].startswith("http://")

def test_timeout_not_passed_when_omitted(self):
"""When no timeout is given, ApiClient is not passed a 'timeout' kwarg (httpx's
own default applies)."""
from th_cli.client import get_client

with patch("th_cli.client.ApiClient") as mock_cls:
mock_cls.return_value = MagicMock()
get_client()

assert "timeout" not in mock_cls.call_args.kwargs

def test_timeout_forwarded_to_api_client(self):
"""An explicit timeout is forwarded to ApiClient (and from there to the
underlying httpx.AsyncClient), instead of callers having to poke
client._async_client.timeout after construction."""
from httpx import Timeout

from th_cli.client import get_client

custom_timeout = Timeout(120.0, connect=10.0)

with patch("th_cli.client.ApiClient") as mock_cls:
mock_cls.return_value = MagicMock()
get_client(timeout=custom_timeout)

assert mock_cls.call_args.kwargs.get("timeout") == custom_timeout


# ---------------------------------------------------------------------------
# Module-level client fallback
Expand Down
Loading
Loading