charisma-cli 0.6.2__tar.gz → 0.6.4__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.6.2 → charisma_cli-0.6.4}/PKG-INFO +1 -1
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/pyproject.toml +1 -1
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/__init__.py +1 -1
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/config.py +9 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/uploader.py +7 -1
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_models.py +39 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_uploader.py +73 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/.gitignore +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/README.md +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/launch_url.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/main.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/models.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/parser.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/read_client.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/read_models.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/retry.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/subprocess_mgr.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/src/charisma_cli/watcher.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/__init__.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/conftest.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_bamboo_labels.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_cli.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_config.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_integration.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_launch_url.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_open_launch_payload.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_parser.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_read_client.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_read_client_attachments.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_read_client_integration.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_read_client_launches.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_read_client_pagination.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_read_client_results.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_read_client_single_result.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_retry.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_silent_mode.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_subprocess_mgr.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_testplan_cmd.py +0 -0
- {charisma_cli-0.6.2 → charisma_cli-0.6.4}/tests/test_watcher.py +0 -0
|
@@ -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.6.
|
|
7
|
+
__version__ = "0.6.4"
|
|
@@ -50,6 +50,8 @@ class Config:
|
|
|
50
50
|
name: str | None = None
|
|
51
51
|
tags: list[str] | None = None
|
|
52
52
|
run_key: str | None = None
|
|
53
|
+
# Charisma rerun job run this build reports for (sent on close).
|
|
54
|
+
job_run_id: str | None = None
|
|
53
55
|
|
|
54
56
|
@classmethod
|
|
55
57
|
def from_env(
|
|
@@ -117,6 +119,12 @@ class Config:
|
|
|
117
119
|
resolved_project = (project or os.getenv("CHARISMA_PROJECT_ID", "")).strip()
|
|
118
120
|
resolved_results = results or os.getenv("CHARISMA_RESULTS", "allure-results")
|
|
119
121
|
resolved_run_key = (run_key or os.getenv("CHARISMA_RUN_KEY", "")).strip() or None
|
|
122
|
+
# A Charisma-triggered rerun passes charisma_job_run_id as a Bamboo build
|
|
123
|
+
# variable, which Bamboo exposes to every task as bamboo_charisma_job_run_id,
|
|
124
|
+
# so no plan change is needed to report the close into that job run.
|
|
125
|
+
resolved_job_run_id = (
|
|
126
|
+
os.getenv("CHARISMA_JOB_RUN_ID") or os.getenv("bamboo_charisma_job_run_id") or ""
|
|
127
|
+
).strip() or None
|
|
120
128
|
resolved_component = (component or _resolve_env("COMPONENT") or "").strip() or None
|
|
121
129
|
resolved_source_url = (source_url or _resolve_env("SOURCE_URL") or "").strip() or None
|
|
122
130
|
resolved_build_plan_key = (build_plan_key or _resolve_env("BUILD_PLAN_KEY") or "").strip() or None
|
|
@@ -185,4 +193,5 @@ class Config:
|
|
|
185
193
|
name=resolved_name,
|
|
186
194
|
tags=resolved_tags,
|
|
187
195
|
run_key=resolved_run_key,
|
|
196
|
+
job_run_id=resolved_job_run_id,
|
|
188
197
|
)
|
|
@@ -460,7 +460,13 @@ class Uploader:
|
|
|
460
460
|
if self._launch_id is None:
|
|
461
461
|
return
|
|
462
462
|
|
|
463
|
-
|
|
463
|
+
payload: dict[str, object] = {}
|
|
464
|
+
if variables:
|
|
465
|
+
payload["variables"] = variables
|
|
466
|
+
if self._config.job_run_id:
|
|
467
|
+
# A rerun reports into its job run, so Charisma keeps the launch's own variables.
|
|
468
|
+
payload["jobRunId"] = self._config.job_run_id
|
|
469
|
+
body = payload or None
|
|
464
470
|
|
|
465
471
|
for attempt in range(MAX_RETRIES + 1):
|
|
466
472
|
try:
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
import pytest
|
|
6
|
+
from hypothesis import given, settings
|
|
7
|
+
from hypothesis import strategies as st
|
|
6
8
|
|
|
7
9
|
from charisma_cli.models import (
|
|
8
10
|
AttachmentRef,
|
|
@@ -266,3 +268,40 @@ class TestUploadSummary:
|
|
|
266
268
|
assert summary.attachments_sent == 3000
|
|
267
269
|
assert summary.attachments_skipped == 100
|
|
268
270
|
assert summary.containers_sent == 800
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
# Preservation (attachment-human-readable-names, Property 2 — Req 3.1).
|
|
274
|
+
# Unicode, whitespace and control characters; no lone surrogates.
|
|
275
|
+
_ANY_TEXT = st.text(alphabet=st.characters(blacklist_categories=("Cs",)), max_size=300)
|
|
276
|
+
_SOURCES = st.uuids().map(lambda u: f"{u}-attachment.json")
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
class TestAttachmentRefNamePreservation:
|
|
280
|
+
"""``from_allure``: a set name is the trimmed label; a blank one falls back to the source."""
|
|
281
|
+
|
|
282
|
+
@settings(max_examples=100, deadline=None)
|
|
283
|
+
@given(name=_ANY_TEXT, source=_SOURCES)
|
|
284
|
+
def test_label_is_trimmed_name_or_source_fallback(self, name: str, source: str) -> None:
|
|
285
|
+
ref = AttachmentRef.from_allure({"source": source, "name": name, "type": "application/json"}, "r-1")
|
|
286
|
+
|
|
287
|
+
assert ref is not None
|
|
288
|
+
assert ref.name == (name.strip() or source)
|
|
289
|
+
assert ref.source == source
|
|
290
|
+
assert ref.name.strip() != ""
|
|
291
|
+
|
|
292
|
+
@settings(max_examples=50, deadline=None)
|
|
293
|
+
@given(source=_SOURCES, blank=st.one_of(st.none(), st.text(alphabet=" \t\n\r\u00a0\u3000", max_size=8)))
|
|
294
|
+
def test_missing_or_whitespace_name_resolves_to_source(self, source: str, blank: str | None) -> None:
|
|
295
|
+
attachment = {"source": source, "type": "application/json"}
|
|
296
|
+
if blank is not None:
|
|
297
|
+
attachment["name"] = blank
|
|
298
|
+
|
|
299
|
+
ref = AttachmentRef.from_allure(attachment, "r-1")
|
|
300
|
+
|
|
301
|
+
assert ref is not None
|
|
302
|
+
assert ref.name == source
|
|
303
|
+
|
|
304
|
+
@settings(max_examples=30, deadline=None)
|
|
305
|
+
@given(name=_ANY_TEXT)
|
|
306
|
+
def test_attachment_without_source_is_ignored(self, name: str) -> None:
|
|
307
|
+
assert AttachmentRef.from_allure({"name": name, "type": "image/png"}, "r-1") is None
|
|
@@ -7,7 +7,10 @@ from pathlib import Path
|
|
|
7
7
|
from queue import PriorityQueue
|
|
8
8
|
|
|
9
9
|
import httpx
|
|
10
|
+
import pytest
|
|
10
11
|
import respx
|
|
12
|
+
from hypothesis import HealthCheck, given, settings
|
|
13
|
+
from hypothesis import strategies as st
|
|
11
14
|
|
|
12
15
|
from charisma_cli.config import Config
|
|
13
16
|
from charisma_cli.models import (
|
|
@@ -2279,3 +2282,73 @@ class TestAttachmentDisplayName:
|
|
|
2279
2282
|
body = self._json_body(route)
|
|
2280
2283
|
assert body["displayName"] == "actual image"
|
|
2281
2284
|
assert body["name"] == self.SOURCE
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
class TestAttachmentUploadPreservation:
|
|
2288
|
+
"""Preservation (attachment-human-readable-names, Property 2 — Req 3.2, 3.3, 3.4).
|
|
2289
|
+
|
|
2290
|
+
``_upload_attachment`` truncates the label at 255, derives the content type
|
|
2291
|
+
from the on-disk filename and falls back to the filename when the label map
|
|
2292
|
+
has no entry. Only the transport (``_post_attachment``) is stubbed.
|
|
2293
|
+
"""
|
|
2294
|
+
|
|
2295
|
+
@settings(
|
|
2296
|
+
max_examples=60, deadline=None, suppress_health_check=[HealthCheck.function_scoped_fixture]
|
|
2297
|
+
)
|
|
2298
|
+
@given(
|
|
2299
|
+
label=st.text(alphabet=st.characters(blacklist_categories=("Cs",)), min_size=1, max_size=600),
|
|
2300
|
+
ext_mime=st.sampled_from(
|
|
2301
|
+
[
|
|
2302
|
+
("png", "image/png"),
|
|
2303
|
+
("json", "application/json"),
|
|
2304
|
+
("txt", "text/plain"),
|
|
2305
|
+
("zzz9", "application/octet-stream"),
|
|
2306
|
+
]
|
|
2307
|
+
),
|
|
2308
|
+
)
|
|
2309
|
+
def test_label_truncated_to_255_and_mime_from_filename(
|
|
2310
|
+
self, tmp_path: Path, label: str, ext_mime: tuple[str, str]
|
|
2311
|
+
) -> None:
|
|
2312
|
+
ext, mime = ext_mime
|
|
2313
|
+
filename = f"9f2c1a7e-attachment.{ext}"
|
|
2314
|
+
path = tmp_path / filename
|
|
2315
|
+
path.write_bytes(b"data")
|
|
2316
|
+
uploader = Uploader(_make_config(), PriorityQueue())
|
|
2317
|
+
uploader._attachment_name_map[filename] = label
|
|
2318
|
+
calls: list[tuple[tuple, dict]] = []
|
|
2319
|
+
uploader._post_attachment = lambda *a, **kw: calls.append((a, kw)) # type: ignore[method-assign]
|
|
2320
|
+
|
|
2321
|
+
uploader._upload_attachment(path, "rid-1")
|
|
2322
|
+
|
|
2323
|
+
assert len(calls) == 1
|
|
2324
|
+
args, kwargs = calls[0]
|
|
2325
|
+
assert args[0] == filename
|
|
2326
|
+
assert args[3] == mime
|
|
2327
|
+
assert kwargs["display_name"] == label[:255]
|
|
2328
|
+
assert len(kwargs["display_name"]) <= 255
|
|
2329
|
+
|
|
2330
|
+
@pytest.mark.parametrize("ext", ["png", "json"])
|
|
2331
|
+
def test_unmapped_attachment_uses_filename_as_label(self, tmp_path: Path, ext: str) -> None:
|
|
2332
|
+
filename = f"spill-error-message.{ext}"
|
|
2333
|
+
path = tmp_path / filename
|
|
2334
|
+
path.write_bytes(b"data")
|
|
2335
|
+
uploader = Uploader(_make_config(), PriorityQueue())
|
|
2336
|
+
calls: list[tuple[tuple, dict]] = []
|
|
2337
|
+
uploader._post_attachment = lambda *a, **kw: calls.append((a, kw)) # type: ignore[method-assign]
|
|
2338
|
+
|
|
2339
|
+
uploader._upload_attachment(path, "rid-1")
|
|
2340
|
+
|
|
2341
|
+
assert calls[0][1]["display_name"] == filename
|
|
2342
|
+
|
|
2343
|
+
|
|
2344
|
+
@respx.mock
|
|
2345
|
+
def test_close_reports_the_bamboo_job_run_id(monkeypatch) -> None:
|
|
2346
|
+
"""Regression: a rerun's close carried no job-run id, so Charisma treated it as a new producer."""
|
|
2347
|
+
for k, v in {"CHARISMA_ENDPOINT": "https://charisma.test", "CHARISMA_TOKEN": "t",
|
|
2348
|
+
"CHARISMA_PROJECT_ID": "p", "bamboo_charisma_job_run_id": "jr-1"}.items():
|
|
2349
|
+
monkeypatch.setenv(k, v)
|
|
2350
|
+
route = respx.post("https://charisma.test/api/v1/launches/l-1/close").mock(return_value=httpx.Response(200))
|
|
2351
|
+
uploader = Uploader(Config.from_env(), PriorityQueue())
|
|
2352
|
+
uploader._launch_id = "l-1"
|
|
2353
|
+
uploader.close_launch(variables={"a": "b"})
|
|
2354
|
+
assert json.loads(route.calls[0].request.content) == {"variables": {"a": "b"}, "jobRunId": "jr-1"}
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|