charisma-cli 0.5.4__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/PKG-INFO +18 -1
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/README.md +17 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/pyproject.toml +1 -1
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/__init__.py +1 -1
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/main.py +52 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/models.py +1 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/parser.py +1 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/read_client.py +20 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/read_models.py +32 -1
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/uploader.py +2 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_read_client_results.py +8 -8
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_read_client_single_result.py +2 -3
- charisma_cli-0.6.0/tests/test_testplan_cmd.py +56 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_uploader.py +14 -3
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/.gitignore +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/config.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/launch_url.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/retry.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/subprocess_mgr.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/src/charisma_cli/watcher.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/__init__.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/conftest.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_bamboo_labels.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_cli.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_config.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_integration.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_launch_url.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_models.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_open_launch_payload.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_parser.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_read_client.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_read_client_attachments.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_read_client_integration.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_read_client_launches.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_read_client_pagination.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_retry.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_silent_mode.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_subprocess_mgr.py +0 -0
- {charisma_cli-0.5.4 → charisma_cli-0.6.0}/tests/test_watcher.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: charisma-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: CLI tool that watches allure-results and streams test results + attachments to Charisma.
|
|
5
5
|
Author: Charisma Team
|
|
6
6
|
License-Expression: MIT
|
|
@@ -120,6 +120,23 @@ summary or a Teams message:
|
|
|
120
120
|
# The same value can feed a Teams-notification step:
|
|
121
121
|
# text: "Results: ${{ steps.charisma.outputs.launch_url }}"
|
|
122
122
|
```
|
|
123
|
+
## Rerun test plan
|
|
124
|
+
|
|
125
|
+
On a Charisma-triggered Bamboo rerun, fetch the plan of failed/broken variants
|
|
126
|
+
before the test task (service token required; CI tokens cannot read launches):
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
charismactl testplan get --project "$PROJECT_UUID" --launch "$LAUNCH_UUID" \
|
|
130
|
+
[--statuses FAILED,BROKEN] --output testplan.json [--format json|pytest-args]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- `json` (default): for `pytest-charisma` via `CHARISMA_TESTPLAN_PATH=testplan.json`.
|
|
134
|
+
- `pytest-args`: one node ID per line for `pytest @testplan.txt`. Exits 1 if the plan
|
|
135
|
+
is empty or has a test a node ID cannot express (an empty list runs the whole suite).
|
|
136
|
+
|
|
137
|
+
`--endpoint`/`--token` fall back to `CHARISMA_ENDPOINT`/`CHARISMA_TOKEN`. `watch`/`upload`
|
|
138
|
+
also forward Allure `titlePath`, which Charisma uses to store each result's node ID.
|
|
139
|
+
|
|
123
140
|
## Read API
|
|
124
141
|
|
|
125
142
|
Alongside the write path (`watch`/`upload`), the package ships an importable **read client** for
|
|
@@ -94,6 +94,23 @@ summary or a Teams message:
|
|
|
94
94
|
# The same value can feed a Teams-notification step:
|
|
95
95
|
# text: "Results: ${{ steps.charisma.outputs.launch_url }}"
|
|
96
96
|
```
|
|
97
|
+
## Rerun test plan
|
|
98
|
+
|
|
99
|
+
On a Charisma-triggered Bamboo rerun, fetch the plan of failed/broken variants
|
|
100
|
+
before the test task (service token required; CI tokens cannot read launches):
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
charismactl testplan get --project "$PROJECT_UUID" --launch "$LAUNCH_UUID" \
|
|
104
|
+
[--statuses FAILED,BROKEN] --output testplan.json [--format json|pytest-args]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- `json` (default): for `pytest-charisma` via `CHARISMA_TESTPLAN_PATH=testplan.json`.
|
|
108
|
+
- `pytest-args`: one node ID per line for `pytest @testplan.txt`. Exits 1 if the plan
|
|
109
|
+
is empty or has a test a node ID cannot express (an empty list runs the whole suite).
|
|
110
|
+
|
|
111
|
+
`--endpoint`/`--token` fall back to `CHARISMA_ENDPOINT`/`CHARISMA_TOKEN`. `watch`/`upload`
|
|
112
|
+
also forward Allure `titlePath`, which Charisma uses to store each result's node ID.
|
|
113
|
+
|
|
97
114
|
## Read API
|
|
98
115
|
|
|
99
116
|
Alongside the write path (`watch`/`upload`), the package ships an importable **read client** for
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
# is generated from pyproject.toml [project].version, so keeping this literal
|
|
5
5
|
# equal to pyproject guarantees `--version` reports the published version. The
|
|
6
6
|
# prepare-commit step owns the PATCH bump — do not hand-bump here.
|
|
7
|
-
__version__ = "0.
|
|
7
|
+
__version__ = "0.6.0"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""CLI entry point for charismactl."""
|
|
2
2
|
|
|
3
|
+
import json
|
|
3
4
|
import signal
|
|
4
5
|
import sys
|
|
5
6
|
from collections.abc import Callable
|
|
@@ -13,6 +14,7 @@ from charisma_cli.config import Config
|
|
|
13
14
|
from charisma_cli.launch_url import build_launch_url, emit_github_output
|
|
14
15
|
from charisma_cli.models import FileEvent
|
|
15
16
|
from charisma_cli.parser import parse_environment_properties
|
|
17
|
+
from charisma_cli.read_client import CharismaReadClient, CharismaReadError
|
|
16
18
|
from charisma_cli.subprocess_mgr import SubprocessManager
|
|
17
19
|
from charisma_cli.uploader import Uploader
|
|
18
20
|
from charisma_cli.watcher import ResultsWatcher, classify_file
|
|
@@ -407,3 +409,53 @@ def upload(
|
|
|
407
409
|
err=True,
|
|
408
410
|
)
|
|
409
411
|
sys.exit(1)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
@cli.group()
|
|
415
|
+
def testplan() -> None:
|
|
416
|
+
"""Fetch the rerun test plan of a launch (failed/broken variants)."""
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
@testplan.command("get")
|
|
420
|
+
@click.option("--endpoint", envvar="CHARISMA_ENDPOINT", required=True, help="Charisma API endpoint.")
|
|
421
|
+
@click.option("--token", envvar="CHARISMA_TOKEN", required=True, help="Service token for the project.")
|
|
422
|
+
@click.option("--project", required=True, help="Project UUID, not the alias (charisma_project_id).")
|
|
423
|
+
@click.option("--launch", "launch_id", required=True, help="Launch UUID to rerun (charisma_launch_id).")
|
|
424
|
+
@click.option("--statuses", default=None, help="Comma-separated statuses (default: FAILED,BROKEN).")
|
|
425
|
+
@click.option("--output", type=click.Path(dir_okay=False, path_type=Path), required=True, help="File to write.")
|
|
426
|
+
@click.option(
|
|
427
|
+
"--format",
|
|
428
|
+
"fmt",
|
|
429
|
+
type=click.Choice(["json", "pytest-args"]),
|
|
430
|
+
default="json",
|
|
431
|
+
help="json: plan for pytest-charisma (CHARISMA_TESTPLAN_PATH). pytest-args: node IDs for `pytest @file`.",
|
|
432
|
+
)
|
|
433
|
+
def testplan_get(
|
|
434
|
+
endpoint: str, token: str, project: str, launch_id: str, statuses: str | None, output: Path, fmt: str
|
|
435
|
+
) -> None:
|
|
436
|
+
"""Write the rerun test plan of LAUNCH to OUTPUT.
|
|
437
|
+
|
|
438
|
+
Usage: charismactl testplan get --project <uuid> --launch <uuid> --output testplan.json
|
|
439
|
+
"""
|
|
440
|
+
try:
|
|
441
|
+
with CharismaReadClient(endpoint, token, project) as client:
|
|
442
|
+
plan = client.get_test_plan(launch_id, statuses)
|
|
443
|
+
except CharismaReadError as exc:
|
|
444
|
+
click.echo(f"Error: could not fetch the test plan: {exc}", err=True)
|
|
445
|
+
sys.exit(1)
|
|
446
|
+
|
|
447
|
+
exact = sum(1 for entry in plan.tests if entry.is_node_id)
|
|
448
|
+
fallback = len(plan.tests) - exact
|
|
449
|
+
if fmt == "pytest-args":
|
|
450
|
+
# An empty @file makes pytest run the whole suite; a function node ID reruns every variant.
|
|
451
|
+
if not plan.tests or fallback:
|
|
452
|
+
click.echo(
|
|
453
|
+
f"Error: {len(plan.tests)} planned test(s), {fallback} not expressible as a pytest node ID. "
|
|
454
|
+
"Use --format json with pytest-charisma (CHARISMA_TESTPLAN_PATH) instead.",
|
|
455
|
+
err=True,
|
|
456
|
+
)
|
|
457
|
+
sys.exit(1)
|
|
458
|
+
output.write_text("".join(f"{entry.selector}\n" for entry in plan.tests), encoding="utf-8")
|
|
459
|
+
else:
|
|
460
|
+
output.write_text(json.dumps(plan.model_dump(by_alias=True), indent=2), encoding="utf-8")
|
|
461
|
+
click.echo(f"Test plan: {len(plan.tests)} test(s) ({exact} exact, {fallback} fallback) -> {output}", err=True)
|
|
@@ -105,6 +105,7 @@ class CharismaResult:
|
|
|
105
105
|
started_at: int | None = None # epoch ms
|
|
106
106
|
ended_at: int | None = None # epoch ms
|
|
107
107
|
uuid: str | None = None # Allure UUID (for attachment linkage)
|
|
108
|
+
title_path: list[str] = field(default_factory=list) # Allure titlePath (backend builds the node ID)
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
@dataclass
|
|
@@ -36,6 +36,7 @@ from charisma_cli.read_models import (
|
|
|
36
36
|
PaginatedLaunchList,
|
|
37
37
|
PaginatedTestResults,
|
|
38
38
|
TestCaseHistoryRecord,
|
|
39
|
+
TestPlan,
|
|
39
40
|
TestResultRecord,
|
|
40
41
|
)
|
|
41
42
|
from charisma_cli.retry import MAX_RETRIES, RETRYABLE_STATUS_CODES, exponential_backoff
|
|
@@ -532,6 +533,25 @@ class CharismaReadClient:
|
|
|
532
533
|
"""
|
|
533
534
|
return self._get_model(self._project_path(f"results/{result_id}"), TestResultRecord)
|
|
534
535
|
|
|
536
|
+
def get_test_plan(self, launch_id: str, statuses: str | None = None) -> TestPlan:
|
|
537
|
+
"""Fetch the rerun test plan for a launch.
|
|
538
|
+
|
|
539
|
+
Args:
|
|
540
|
+
launch_id: The launch UUID.
|
|
541
|
+
statuses: Comma-separated statuses to include; ``None`` uses the server
|
|
542
|
+
default (failed + broken).
|
|
543
|
+
|
|
544
|
+
Returns:
|
|
545
|
+
The plan as a ``TestPlan``.
|
|
546
|
+
|
|
547
|
+
Raises:
|
|
548
|
+
CharismaNotFoundError: If the launch is not in this project (HTTP 404).
|
|
549
|
+
CharismaAuthError: On an auth failure.
|
|
550
|
+
CharismaReadError: On a 400 (bad status) or a persistent server failure.
|
|
551
|
+
"""
|
|
552
|
+
params: dict[str, object] | None = {"statuses": statuses} if statuses else None
|
|
553
|
+
return self._get_model(self._project_path(f"launches/{launch_id}/test-plan"), TestPlan, params)
|
|
554
|
+
|
|
535
555
|
def get_result_execution(self, result_id: str) -> ExecutionRecord:
|
|
536
556
|
"""Fetch the execution tree for a test result (FR-4).
|
|
537
557
|
|
|
@@ -173,7 +173,6 @@ class TestResultRecord(_CamelModel):
|
|
|
173
173
|
ended_at: datetime | None = None
|
|
174
174
|
duration_ms: int | None = None
|
|
175
175
|
retry_count: int | None = None
|
|
176
|
-
attempt_number: int | None = None
|
|
177
176
|
is_final: bool | None = None
|
|
178
177
|
history_id: str | None = None
|
|
179
178
|
effective_retention_policy: str | None = None
|
|
@@ -309,3 +308,35 @@ class TestCaseHistoryRecord(_SnakeModel):
|
|
|
309
308
|
executions: list[ExecutionEntryRecord]
|
|
310
309
|
stability: StabilityResultRecord
|
|
311
310
|
status_change_badge: str | None = None
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
# ===========================================================================
|
|
314
|
+
# Rerun test plan (camelCase wire)
|
|
315
|
+
# ===========================================================================
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
class TestPlanEntry(_CamelModel):
|
|
319
|
+
"""One planned test: exact node ID (``selector``) or a fallback identity."""
|
|
320
|
+
|
|
321
|
+
selector: str | None = None
|
|
322
|
+
full_name: str | None = None
|
|
323
|
+
name: str
|
|
324
|
+
parameters: dict[str, str] = {}
|
|
325
|
+
|
|
326
|
+
@property
|
|
327
|
+
def is_node_id(self) -> bool:
|
|
328
|
+
"""True when ``selector`` alone picks exactly this variant.
|
|
329
|
+
|
|
330
|
+
A ``@allure.title`` variant carries the function node ID plus parameters;
|
|
331
|
+
as a bare node ID it would rerun every variant of that function.
|
|
332
|
+
"""
|
|
333
|
+
if self.selector is None:
|
|
334
|
+
return False
|
|
335
|
+
return self.selector.endswith("]") or not self.parameters
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
class TestPlan(_CamelModel):
|
|
339
|
+
"""The rerun test plan served by ``GET .../launches/{launchId}/test-plan``."""
|
|
340
|
+
|
|
341
|
+
version: str
|
|
342
|
+
tests: list[TestPlanEntry]
|
|
@@ -564,6 +564,8 @@ class Uploader:
|
|
|
564
564
|
payload["name"] = result.name
|
|
565
565
|
if result.full_name:
|
|
566
566
|
payload["full_name"] = result.full_name
|
|
567
|
+
if result.title_path:
|
|
568
|
+
payload["title_path"] = result.title_path
|
|
567
569
|
if result.error_message:
|
|
568
570
|
payload["error_message"] = self._spill_oversized_field(
|
|
569
571
|
result.error_message,
|
|
@@ -114,7 +114,6 @@ def _test_result_row(result_id: str, name: str, status: str, attempt: int, is_fi
|
|
|
114
114
|
"endedAt": "2026-06-20T09:14:12.640000+00:00",
|
|
115
115
|
"durationMs": 2540,
|
|
116
116
|
"retryCount": 1 if attempt > 1 else 0,
|
|
117
|
-
"attemptNumber": attempt,
|
|
118
117
|
"isFinal": is_final,
|
|
119
118
|
"historyId": "hist-7d3e9a1b",
|
|
120
119
|
"effectiveRetentionPolicy": "default-90d",
|
|
@@ -180,15 +179,15 @@ class TestListLaunchResultsEnvelope:
|
|
|
180
179
|
|
|
181
180
|
@respx.mock
|
|
182
181
|
def test_items_are_flat_per_attempt_rows(self) -> None:
|
|
183
|
-
"""Items are flat per-attempt rows: the same result id appears once per
|
|
182
|
+
"""Items are flat per-attempt rows: the same result id appears once per execution."""
|
|
184
183
|
respx.get(RESULTS_URL).mock(return_value=httpx.Response(200, json=RESULTS_ENVELOPE))
|
|
185
184
|
client = _make_client()
|
|
186
185
|
items = client.list_launch_results(LAUNCH_ID).items
|
|
187
|
-
attempts = [(item.name, item.
|
|
186
|
+
attempts = [(item.name, item.is_final) for item in items]
|
|
188
187
|
assert attempts == [
|
|
189
|
-
("test_pay_with_card",
|
|
190
|
-
("test_pay_with_card",
|
|
191
|
-
("test_apply_coupon",
|
|
188
|
+
("test_pay_with_card", False),
|
|
189
|
+
("test_pay_with_card", True),
|
|
190
|
+
("test_apply_coupon", True),
|
|
192
191
|
]
|
|
193
192
|
|
|
194
193
|
@respx.mock
|
|
@@ -199,7 +198,7 @@ class TestListLaunchResultsEnvelope:
|
|
|
199
198
|
first = client.list_launch_results(LAUNCH_ID).items[0]
|
|
200
199
|
snake_attrs = (
|
|
201
200
|
"launch_id", "launch_created_at", "project_id", "full_name", "error_message",
|
|
202
|
-
"stack_trace", "error_phase", "duration_ms", "retry_count",
|
|
201
|
+
"stack_trace", "error_phase", "duration_ms", "retry_count",
|
|
203
202
|
"is_final", "history_id", "effective_retention_policy", "retention_policy_name",
|
|
204
203
|
"expires_at", "feature_name", "feature_description", "base_test_name",
|
|
205
204
|
"is_parameterized", "workflow_status", "component_id", "metadata_tags",
|
|
@@ -210,7 +209,7 @@ class TestListLaunchResultsEnvelope:
|
|
|
210
209
|
wire = first.model_dump(by_alias=True)
|
|
211
210
|
for key in (
|
|
212
211
|
"launchId", "launchCreatedAt", "projectId", "fullName", "errorMessage",
|
|
213
|
-
"stackTrace", "errorPhase", "durationMs", "retryCount",
|
|
212
|
+
"stackTrace", "errorPhase", "durationMs", "retryCount",
|
|
214
213
|
"isFinal", "historyId", "effectiveRetentionPolicy", "retentionPolicyName",
|
|
215
214
|
"expiresAt", "featureName", "featureDescription", "baseTestName",
|
|
216
215
|
"isParameterized", "workflowStatus", "componentId", "metadataTags",
|
|
@@ -219,6 +218,7 @@ class TestListLaunchResultsEnvelope:
|
|
|
219
218
|
assert key in wire
|
|
220
219
|
|
|
221
220
|
|
|
221
|
+
|
|
222
222
|
class TestListLaunchResultsTagsPopulated:
|
|
223
223
|
"""results-list path: tags / metadataTags / zephyrIds are POPULATED (contrast get_result, where they are [])."""
|
|
224
224
|
|
|
@@ -133,7 +133,6 @@ RESULT_RECORD = {
|
|
|
133
133
|
"endedAt": "2026-06-20T09:14:12.640000+00:00",
|
|
134
134
|
"durationMs": 2540,
|
|
135
135
|
"retryCount": 0,
|
|
136
|
-
"attemptNumber": 1,
|
|
137
136
|
"isFinal": True,
|
|
138
137
|
"historyId": "hist-7d3e9a1b",
|
|
139
138
|
"effectiveRetentionPolicy": "default-90d",
|
|
@@ -274,14 +273,14 @@ class TestGetResultVerbatim:
|
|
|
274
273
|
client = _make_client()
|
|
275
274
|
result = client.get_result(RESULT_ID)
|
|
276
275
|
for attr in (
|
|
277
|
-
"launch_id", "project_id", "full_name", "duration_ms",
|
|
276
|
+
"launch_id", "project_id", "full_name", "duration_ms",
|
|
278
277
|
"is_final", "history_id", "base_test_name", "workflow_status", "component_id",
|
|
279
278
|
"created_at",
|
|
280
279
|
):
|
|
281
280
|
assert hasattr(result, attr)
|
|
282
281
|
wire = result.model_dump(by_alias=True)
|
|
283
282
|
for key in (
|
|
284
|
-
"launchId", "projectId", "fullName", "durationMs", "
|
|
283
|
+
"launchId", "projectId", "fullName", "durationMs", "isFinal",
|
|
285
284
|
"historyId", "baseTestName", "workflowStatus", "componentId", "createdAt",
|
|
286
285
|
):
|
|
287
286
|
assert key in wire
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""`charismactl testplan get`: fetch the rerun test plan to a file."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
import pytest
|
|
8
|
+
import respx
|
|
9
|
+
from click.testing import CliRunner
|
|
10
|
+
|
|
11
|
+
from charisma_cli.main import cli
|
|
12
|
+
|
|
13
|
+
ENDPOINT = "https://charisma.test"
|
|
14
|
+
PROJECT = "123e4567-e89b-12d3-a456-426614174000"
|
|
15
|
+
LAUNCH = "9f8e7d6c-5b4a-3210-fedc-ba9876543210"
|
|
16
|
+
PLAN_URL = f"{ENDPOINT}/api/v1/projects/{PROJECT}/launches/{LAUNCH}/test-plan"
|
|
17
|
+
|
|
18
|
+
EXACT = {"selector": "tests/t.py::test_a[x]", "fullName": "tests.t#test_a", "name": "test_a[x]", "parameters": {}}
|
|
19
|
+
TITLED = {"selector": "tests/t.py::test_b", "fullName": "tests.t#test_b", "name": "B", "parameters": {"u": "'x'"}}
|
|
20
|
+
NO_SELECTOR = {"selector": None, "fullName": "tests.t#test_c", "name": "test_c", "parameters": {}}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _run(tmp_path: Path, tests: list[dict], fmt: str) -> tuple[int, Path, respx.Route]:
|
|
24
|
+
route = respx.get(PLAN_URL).mock(return_value=httpx.Response(200, json={"version": "1.0", "tests": tests}))
|
|
25
|
+
out = tmp_path / "plan.out"
|
|
26
|
+
args = ["testplan", "get", "--endpoint", ENDPOINT, "--token", "t", "--project", PROJECT,
|
|
27
|
+
"--launch", LAUNCH, "--statuses", "FAILED", "--output", str(out), "--format", fmt]
|
|
28
|
+
result = CliRunner().invoke(cli, args)
|
|
29
|
+
return result.exit_code, out, route
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@respx.mock
|
|
33
|
+
def test_json_format_writes_plan_and_sends_statuses(tmp_path: Path) -> None:
|
|
34
|
+
code, out, route = _run(tmp_path, [EXACT, NO_SELECTOR], "json")
|
|
35
|
+
|
|
36
|
+
assert code == 0
|
|
37
|
+
assert route.calls.last.request.url.params["statuses"] == "FAILED"
|
|
38
|
+
assert json.loads(out.read_text())["tests"][1]["fullName"] == "tests.t#test_c"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@respx.mock
|
|
42
|
+
def test_pytest_args_writes_one_selector_per_line(tmp_path: Path) -> None:
|
|
43
|
+
code, out, _ = _run(tmp_path, [EXACT, {**EXACT, "selector": "tests/t.py::test_d"}], "pytest-args")
|
|
44
|
+
|
|
45
|
+
assert code == 0
|
|
46
|
+
assert out.read_text().splitlines() == ["tests/t.py::test_a[x]", "tests/t.py::test_d"]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# An empty @file runs the whole suite; a function ID reruns every variant.
|
|
50
|
+
@pytest.mark.parametrize("tests", [[], [EXACT, NO_SELECTOR], [EXACT, TITLED]])
|
|
51
|
+
@respx.mock
|
|
52
|
+
def test_pytest_args_refuses_unexpressible_plan(tmp_path: Path, tests: list[dict]) -> None:
|
|
53
|
+
code, out, _ = _run(tmp_path, tests, "pytest-args")
|
|
54
|
+
|
|
55
|
+
assert code == 1
|
|
56
|
+
assert not out.exists()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Unit tests for charisma_cli.uploader: batching, drain, priority ordering, error handling."""
|
|
2
2
|
|
|
3
|
+
import json
|
|
3
4
|
import threading
|
|
4
5
|
import time
|
|
5
6
|
from pathlib import Path
|
|
@@ -570,9 +571,8 @@ class TestAttachmentResultIdContract:
|
|
|
570
571
|
"""The attachment `resultId` must be the backend id returned by /results.
|
|
571
572
|
|
|
572
573
|
Regression for the `attachments_sent=0, attachments_skipped=N` production bug.
|
|
573
|
-
Under retries (ADR-031) the backend
|
|
574
|
-
|
|
575
|
-
and unknown to the client. The client therefore reads the backend-assigned
|
|
574
|
+
Under retries (ADR-031) the backend assigns test_results.id server-side
|
|
575
|
+
(uuid4), unknown to the client. The client therefore reads the backend-assigned
|
|
576
576
|
resultId from the append-results response (`results: [{testId, resultId}]`)
|
|
577
577
|
and sends THAT exact id on the attachment. Sending the raw Allure `uuid`, the
|
|
578
578
|
historyId, or a client-computed uuid5 never matches and every attachment is
|
|
@@ -1886,6 +1886,17 @@ class TestUploaderTagLabels:
|
|
|
1886
1886
|
assert payload.get("tags") == ["smilevid"]
|
|
1887
1887
|
assert "tag" not in (payload.get("labels") or {})
|
|
1888
1888
|
|
|
1889
|
+
@respx.mock
|
|
1890
|
+
def test_title_path_forwarded_for_rerun_selector(self, tmp_path: Path) -> None:
|
|
1891
|
+
"""Allure titlePath reaches the wire so the backend can build the pytest node ID."""
|
|
1892
|
+
result_file = self._result_with_labels(tmp_path, [])
|
|
1893
|
+
data = json.loads(result_file.read_text(encoding="utf-8"))
|
|
1894
|
+
data["titlePath"] = ["tests", "test_auth.py", "TestLogin"]
|
|
1895
|
+
self._write_json(result_file, data)
|
|
1896
|
+
payload = self._upload_and_capture(_make_config(), result_file)
|
|
1897
|
+
|
|
1898
|
+
assert payload.get("title_path") == ["tests", "test_auth.py", "TestLogin"]
|
|
1899
|
+
|
|
1889
1900
|
@respx.mock
|
|
1890
1901
|
def test_duplicate_tag_values_deduped_in_encounter_order(self, tmp_path: Path) -> None:
|
|
1891
1902
|
"""Repeated identical tag values are de-duplicated, preserving first-seen order.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|