charisma-cli 0.5.3__tar.gz → 0.5.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.5.3 → charisma_cli-0.5.4}/PKG-INFO +1 -1
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/pyproject.toml +1 -1
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/__init__.py +1 -1
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/models.py +3 -1
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/uploader.py +48 -6
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_models.py +22 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_uploader.py +208 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/.gitignore +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/README.md +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/config.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/launch_url.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/main.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/parser.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/read_client.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/read_models.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/retry.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/subprocess_mgr.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/src/charisma_cli/watcher.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/__init__.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/conftest.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_bamboo_labels.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_cli.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_config.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_integration.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_launch_url.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_open_launch_payload.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_parser.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_read_client.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_read_client_attachments.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_read_client_integration.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_read_client_launches.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_read_client_pagination.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_read_client_results.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_read_client_single_result.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_retry.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_silent_mode.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.4}/tests/test_subprocess_mgr.py +0 -0
- {charisma_cli-0.5.3 → charisma_cli-0.5.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.5.
|
|
7
|
+
__version__ = "0.5.4"
|
|
@@ -133,7 +133,9 @@ class AttachmentRef:
|
|
|
133
133
|
return None
|
|
134
134
|
return cls(
|
|
135
135
|
source=source,
|
|
136
|
-
name
|
|
136
|
+
# An empty/blank/null Allure name must not become a blank label:
|
|
137
|
+
# fall back to the source filename.
|
|
138
|
+
name=(attachment.get("name") or "").strip() or source,
|
|
137
139
|
mime_type=attachment.get("type", "application/octet-stream"),
|
|
138
140
|
result_uuid=result_uuid,
|
|
139
141
|
)
|
|
@@ -83,6 +83,10 @@ def _resolve_apigw_safe_bytes() -> int:
|
|
|
83
83
|
# presign-signed Content-Type and the PUT Content-Type match byte-for-byte.
|
|
84
84
|
_SPILL_CONTENT_TYPE = "text/plain; charset=utf-8"
|
|
85
85
|
|
|
86
|
+
# The backend rejects a displayName longer than this (400). Truncate the Allure
|
|
87
|
+
# label client-side so an overlong name never costs the attachment itself.
|
|
88
|
+
_MAX_DISPLAY_NAME_LEN = 255
|
|
89
|
+
|
|
86
90
|
# Sentinel expectedTests for CLI launches: the total count is unknown at open
|
|
87
91
|
# time (directory-watch streaming), so we send the backend maximum. This keeps
|
|
88
92
|
# the launch in 'receiving' across all appends; close_launch() finalizes it.
|
|
@@ -130,6 +134,10 @@ class Uploader:
|
|
|
130
134
|
# Allure's own structure: results own attachments and have a uuid;
|
|
131
135
|
# containers reference their children by uuid).
|
|
132
136
|
self._attachment_result_map: dict[str, str] = {}
|
|
137
|
+
# Map source filename → Allure attachment name (the human label such as
|
|
138
|
+
# "actual image"). Sent as ``displayName`` so listings are not the bare
|
|
139
|
+
# ``<uuid>-attachment.png`` filename. Written beside the result map.
|
|
140
|
+
self._attachment_name_map: dict[str, str] = {}
|
|
133
141
|
# Map Allure result uuid → historyId. Attachments reference their owning
|
|
134
142
|
# result by Allure uuid; the backend keys results by historyId, so the
|
|
135
143
|
# uuid must be translated to its historyId. Populated as result files are
|
|
@@ -755,6 +763,7 @@ class Uploader:
|
|
|
755
763
|
return
|
|
756
764
|
for ref in refs:
|
|
757
765
|
self._attachment_result_map[ref.source] = ref.result_uuid
|
|
766
|
+
self._attachment_name_map[ref.source] = ref.name
|
|
758
767
|
# A newly-registered mapping may unblock attachments that were dequeued
|
|
759
768
|
# before their owning result/container arrived (watch-mode ordering).
|
|
760
769
|
self._retry_pending_attachments()
|
|
@@ -861,10 +870,23 @@ class Uploader:
|
|
|
861
870
|
# would diverge from the signature). Same fallback the backend's own
|
|
862
871
|
# handle_upload_attachment uses.
|
|
863
872
|
content_type = mimetypes.guess_type(path.name)[0] or "application/octet-stream"
|
|
864
|
-
self._post_attachment(
|
|
873
|
+
self._post_attachment(
|
|
874
|
+
path.name,
|
|
875
|
+
content,
|
|
876
|
+
result_id,
|
|
877
|
+
content_type,
|
|
878
|
+
display_name=self._attachment_name_map.get(path.name, path.name)[
|
|
879
|
+
:_MAX_DISPLAY_NAME_LEN
|
|
880
|
+
],
|
|
881
|
+
)
|
|
865
882
|
|
|
866
883
|
def _post_attachment(
|
|
867
|
-
self,
|
|
884
|
+
self,
|
|
885
|
+
filename: str,
|
|
886
|
+
content: bytes,
|
|
887
|
+
result_id: str,
|
|
888
|
+
content_type: str,
|
|
889
|
+
display_name: str | None = None,
|
|
868
890
|
) -> None:
|
|
869
891
|
"""POST attachment bytes to Charisma, routing by size.
|
|
870
892
|
|
|
@@ -887,6 +909,10 @@ class Uploader:
|
|
|
887
909
|
content: Raw attachment bytes.
|
|
888
910
|
result_id: Backend-assigned ``test_results.id`` for the owning result.
|
|
889
911
|
content_type: Concrete MIME type (never None).
|
|
912
|
+
display_name: Human label (the Allure attachment name) sent as
|
|
913
|
+
``displayName`` so listings show it instead of the filename.
|
|
914
|
+
``None`` omits the field (e.g. oversized-field spills have no
|
|
915
|
+
Allure name).
|
|
890
916
|
"""
|
|
891
917
|
if self._client is None or not self._launch_id:
|
|
892
918
|
self._summary.attachments_skipped += 1
|
|
@@ -894,11 +920,13 @@ class Uploader:
|
|
|
894
920
|
return
|
|
895
921
|
|
|
896
922
|
if len(content) > self._attachment_apigw_safe_bytes:
|
|
897
|
-
self._post_attachment_via_s3(filename, content, result_id, content_type)
|
|
923
|
+
self._post_attachment_via_s3(filename, content, result_id, content_type, display_name)
|
|
898
924
|
else:
|
|
899
|
-
self._post_attachment_apigw(filename, content, result_id)
|
|
925
|
+
self._post_attachment_apigw(filename, content, result_id, display_name)
|
|
900
926
|
|
|
901
|
-
def _post_attachment_apigw(
|
|
927
|
+
def _post_attachment_apigw(
|
|
928
|
+
self, filename: str, content: bytes, result_id: str, display_name: str | None = None
|
|
929
|
+
) -> None:
|
|
902
930
|
"""POST attachment bytes via the API-Gateway multipart route, with retry.
|
|
903
931
|
|
|
904
932
|
The original (and still default, for content at or below the routing
|
|
@@ -913,9 +941,12 @@ class Uploader:
|
|
|
913
941
|
content: Raw attachment bytes.
|
|
914
942
|
result_id: Backend-assigned ``test_results.id`` for the owning result
|
|
915
943
|
(from the append-results response), sent as ``resultId``.
|
|
944
|
+
display_name: Allure attachment label, sent as ``displayName`` when set.
|
|
916
945
|
"""
|
|
917
946
|
files = {"file": (filename, content)}
|
|
918
947
|
data = {"name": filename, "resultId": result_id}
|
|
948
|
+
if display_name:
|
|
949
|
+
data["displayName"] = display_name
|
|
919
950
|
|
|
920
951
|
for attempt in range(MAX_RETRIES + 1):
|
|
921
952
|
try:
|
|
@@ -1006,7 +1037,12 @@ class Uploader:
|
|
|
1006
1037
|
return None
|
|
1007
1038
|
|
|
1008
1039
|
def _post_attachment_via_s3(
|
|
1009
|
-
self,
|
|
1040
|
+
self,
|
|
1041
|
+
filename: str,
|
|
1042
|
+
content: bytes,
|
|
1043
|
+
result_id: str,
|
|
1044
|
+
content_type: str,
|
|
1045
|
+
display_name: str | None = None,
|
|
1010
1046
|
) -> None:
|
|
1011
1047
|
"""Upload a large attachment via presign -> direct S3 PUT -> complete.
|
|
1012
1048
|
|
|
@@ -1036,6 +1072,8 @@ class Uploader:
|
|
|
1036
1072
|
result_id: Backend-assigned ``test_results.id`` for the owning result.
|
|
1037
1073
|
content_type: Concrete MIME type, signed into the presigned URL and
|
|
1038
1074
|
echoed verbatim on the PUT and complete steps.
|
|
1075
|
+
display_name: Allure attachment label, sent as ``displayName`` on the
|
|
1076
|
+
presign and complete requests when set.
|
|
1039
1077
|
"""
|
|
1040
1078
|
presign_body = {
|
|
1041
1079
|
"resultId": result_id,
|
|
@@ -1043,6 +1081,8 @@ class Uploader:
|
|
|
1043
1081
|
"contentType": content_type,
|
|
1044
1082
|
"size": len(content),
|
|
1045
1083
|
}
|
|
1084
|
+
if display_name:
|
|
1085
|
+
presign_body["displayName"] = display_name
|
|
1046
1086
|
presign_resp = self._request_with_retry(
|
|
1047
1087
|
"presign",
|
|
1048
1088
|
filename,
|
|
@@ -1102,6 +1142,8 @@ class Uploader:
|
|
|
1102
1142
|
"contentType": content_type,
|
|
1103
1143
|
"s3Key": s3_key,
|
|
1104
1144
|
}
|
|
1145
|
+
if display_name:
|
|
1146
|
+
complete_body["displayName"] = display_name
|
|
1105
1147
|
complete_resp = self._request_with_retry(
|
|
1106
1148
|
"complete",
|
|
1107
1149
|
filename,
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
5
7
|
from charisma_cli.models import (
|
|
6
8
|
AttachmentRef,
|
|
7
9
|
CharismaResult,
|
|
@@ -148,6 +150,26 @@ class TestAttachmentRef:
|
|
|
148
150
|
assert ref.mime_type == "image/png"
|
|
149
151
|
assert ref.result_uuid == "result-uuid-456"
|
|
150
152
|
|
|
153
|
+
def test_from_allure_keeps_allure_name(self) -> None:
|
|
154
|
+
"""A set Allure name is the human label (e.g. 'actual image')."""
|
|
155
|
+
ref = AttachmentRef.from_allure(
|
|
156
|
+
{"source": "9f2-attachment.png", "name": "actual image", "type": "image/png"},
|
|
157
|
+
"res-1",
|
|
158
|
+
)
|
|
159
|
+
assert ref is not None
|
|
160
|
+
assert ref.name == "actual image"
|
|
161
|
+
assert ref.source == "9f2-attachment.png"
|
|
162
|
+
|
|
163
|
+
@pytest.mark.parametrize("attachment_name", ["", " ", None])
|
|
164
|
+
def test_from_allure_empty_name_falls_back_to_source(self, attachment_name) -> None:
|
|
165
|
+
"""An empty/blank/null Allure name must not yield a blank label."""
|
|
166
|
+
attachment = {"source": "9f2-attachment.png", "type": "image/png"}
|
|
167
|
+
if attachment_name is not None:
|
|
168
|
+
attachment["name"] = attachment_name
|
|
169
|
+
ref = AttachmentRef.from_allure(attachment, "res-1")
|
|
170
|
+
assert ref is not None
|
|
171
|
+
assert ref.name == "9f2-attachment.png"
|
|
172
|
+
|
|
151
173
|
def test_different_mime_types(self) -> None:
|
|
152
174
|
for mime in ["text/plain", "application/json", "video/mp4", "image/jpeg"]:
|
|
153
175
|
ref = AttachmentRef(source="file", name="f", mime_type=mime, result_uuid="r")
|
|
@@ -2060,3 +2060,211 @@ class TestUploaderStopTimeoutAndWarning:
|
|
|
2060
2060
|
"Uploader.stop must accept a configurable 'timeout' (the 10s join "
|
|
2061
2061
|
"was hardcoded, cutting off large/slow uploads)"
|
|
2062
2062
|
)
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
class TestAttachmentDisplayName:
|
|
2066
|
+
"""The Allure attachment name reaches the backend as ``displayName``.
|
|
2067
|
+
|
|
2068
|
+
Bug: attachments showed as ``<uuid>-attachment.png`` because the CLI sent the
|
|
2069
|
+
on-disk filename as the only ``name`` and never the Allure label ("actual
|
|
2070
|
+
image" / "expected image"). ``name`` must stay the real filename (the backend
|
|
2071
|
+
derives extension, MIME and S3 key from it); the human label travels in
|
|
2072
|
+
``displayName`` on every transport (multipart, presign, complete). An empty
|
|
2073
|
+
Allure name falls back to the filename so the label is never blank.
|
|
2074
|
+
"""
|
|
2075
|
+
|
|
2076
|
+
LAUNCH = "launch-1"
|
|
2077
|
+
RESULTS_URL = f"https://charisma.test/api/v1/launches/{LAUNCH}/results"
|
|
2078
|
+
APIGW_URL = f"https://charisma.test/api/v1/launches/{LAUNCH}/attachments"
|
|
2079
|
+
PRESIGN_URL = f"https://charisma.test/api/v1/launches/{LAUNCH}/attachments/presign"
|
|
2080
|
+
COMPLETE_URL = f"https://charisma.test/api/v1/launches/{LAUNCH}/attachments/complete"
|
|
2081
|
+
S3_PUT_URL = "https://s3.amazonaws.com/charisma-bucket/attachments/p/l/r/obj.png?sig=abc"
|
|
2082
|
+
SOURCE = "9f2c1a7e-attachment.png"
|
|
2083
|
+
|
|
2084
|
+
@staticmethod
|
|
2085
|
+
def _multipart_field(route, field: str) -> str | None:
|
|
2086
|
+
"""Return a multipart form field value from the first recorded request."""
|
|
2087
|
+
body = route.calls[0].request.content.decode("utf-8", errors="replace")
|
|
2088
|
+
marker = f'name="{field}"'
|
|
2089
|
+
idx = body.find(marker)
|
|
2090
|
+
if idx == -1:
|
|
2091
|
+
return None
|
|
2092
|
+
value = body[idx + len(marker):].split("\r\n\r\n", 1)[1]
|
|
2093
|
+
return value.split("\r\n", 1)[0]
|
|
2094
|
+
|
|
2095
|
+
@staticmethod
|
|
2096
|
+
def _json_body(route) -> dict:
|
|
2097
|
+
import json
|
|
2098
|
+
|
|
2099
|
+
return json.loads(route.calls[0].request.content)
|
|
2100
|
+
|
|
2101
|
+
def _run(self, tmp_path: Path, result: dict, files: dict[str, bytes], monkeypatch,
|
|
2102
|
+
threshold: int = 1024 * 1024) -> Uploader:
|
|
2103
|
+
"""Upload one result plus its attachment files through a real Uploader."""
|
|
2104
|
+
import json
|
|
2105
|
+
|
|
2106
|
+
monkeypatch.setenv("CHARISMA_ATTACHMENT_APIGW_SAFE_BYTES", str(threshold))
|
|
2107
|
+
monkeypatch.setattr("charisma_cli.uploader.exponential_backoff", lambda attempt: 0.0)
|
|
2108
|
+
queue: PriorityQueue = PriorityQueue()
|
|
2109
|
+
uploader = Uploader(_make_config(), queue)
|
|
2110
|
+
uploader._launch_id = self.LAUNCH
|
|
2111
|
+
|
|
2112
|
+
result_file = tmp_path / "r1-result.json"
|
|
2113
|
+
result_file.write_text(json.dumps(result), encoding="utf-8")
|
|
2114
|
+
queue.put(FileEvent(path=result_file, category=FileCategory.RESULT))
|
|
2115
|
+
for fname, content in files.items():
|
|
2116
|
+
(tmp_path / fname).write_bytes(content)
|
|
2117
|
+
queue.put(FileEvent(path=tmp_path / fname, category=FileCategory.ATTACHMENT))
|
|
2118
|
+
|
|
2119
|
+
uploader.start()
|
|
2120
|
+
uploader.drain(timeout=5.0)
|
|
2121
|
+
uploader.stop()
|
|
2122
|
+
return uploader
|
|
2123
|
+
|
|
2124
|
+
@staticmethod
|
|
2125
|
+
def _result(attachments: list[dict], steps: list[dict] | None = None) -> dict:
|
|
2126
|
+
result = {
|
|
2127
|
+
"uuid": "r1", "historyId": "hist-r1", "fullName": "atd.png_check",
|
|
2128
|
+
"status": "failed", "start": 1000, "stop": 2000, "attachments": attachments,
|
|
2129
|
+
}
|
|
2130
|
+
if steps is not None:
|
|
2131
|
+
result["steps"] = steps
|
|
2132
|
+
return result
|
|
2133
|
+
|
|
2134
|
+
def _mock_results(self) -> None:
|
|
2135
|
+
respx.post(self.RESULTS_URL).mock(
|
|
2136
|
+
return_value=httpx.Response(200, json={
|
|
2137
|
+
"accepted": 1, "results": [{"testId": "hist-r1", "resultId": "rid-r1"}],
|
|
2138
|
+
})
|
|
2139
|
+
)
|
|
2140
|
+
|
|
2141
|
+
@respx.mock
|
|
2142
|
+
def test_multipart_sends_allure_name_as_display_name_and_filename_as_name(
|
|
2143
|
+
self, tmp_path: Path, monkeypatch
|
|
2144
|
+
) -> None:
|
|
2145
|
+
"""API-GW multipart: ``displayName`` is the Allure label, ``name`` the filename."""
|
|
2146
|
+
self._mock_results()
|
|
2147
|
+
route = respx.post(self.APIGW_URL).mock(return_value=httpx.Response(201, json={"id": "a"}))
|
|
2148
|
+
|
|
2149
|
+
uploader = self._run(
|
|
2150
|
+
tmp_path,
|
|
2151
|
+
self._result([{"source": self.SOURCE, "name": "actual image", "type": "image/png"}]),
|
|
2152
|
+
{self.SOURCE: b"\x89PNG fake"},
|
|
2153
|
+
monkeypatch,
|
|
2154
|
+
)
|
|
2155
|
+
|
|
2156
|
+
assert uploader.summary.attachments_sent == 1
|
|
2157
|
+
assert self._multipart_field(route, "displayName") == "actual image"
|
|
2158
|
+
assert self._multipart_field(route, "name") == self.SOURCE
|
|
2159
|
+
|
|
2160
|
+
@respx.mock
|
|
2161
|
+
def test_two_attachments_keep_their_own_labels(self, tmp_path: Path, monkeypatch) -> None:
|
|
2162
|
+
"""The ATD pattern: 'actual image' and 'expected image' stay distinguishable."""
|
|
2163
|
+
self._mock_results()
|
|
2164
|
+
route = respx.post(self.APIGW_URL).mock(return_value=httpx.Response(201, json={"id": "a"}))
|
|
2165
|
+
expected_src = "77ab-attachment.png"
|
|
2166
|
+
|
|
2167
|
+
self._run(
|
|
2168
|
+
tmp_path,
|
|
2169
|
+
self._result([
|
|
2170
|
+
{"source": self.SOURCE, "name": "actual image", "type": "image/png"},
|
|
2171
|
+
{"source": expected_src, "name": "expected image", "type": "image/png"},
|
|
2172
|
+
]),
|
|
2173
|
+
{self.SOURCE: b"actual-bytes", expected_src: b"expected-bytes"},
|
|
2174
|
+
monkeypatch,
|
|
2175
|
+
)
|
|
2176
|
+
|
|
2177
|
+
labels_by_filename = {}
|
|
2178
|
+
for call in route.calls:
|
|
2179
|
+
body = call.request.content.decode("utf-8", errors="replace")
|
|
2180
|
+
def field(f: str) -> str:
|
|
2181
|
+
value = body[body.find(f'name="{f}"') + len(f'name="{f}"'):]
|
|
2182
|
+
return value.split("\r\n\r\n", 1)[1].split("\r\n", 1)[0]
|
|
2183
|
+
labels_by_filename[field("name")] = field("displayName")
|
|
2184
|
+
assert labels_by_filename == {
|
|
2185
|
+
self.SOURCE: "actual image",
|
|
2186
|
+
expected_src: "expected image",
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
@respx.mock
|
|
2190
|
+
def test_empty_allure_name_falls_back_to_filename(self, tmp_path: Path, monkeypatch) -> None:
|
|
2191
|
+
"""An empty Allure name must not produce a blank displayName."""
|
|
2192
|
+
self._mock_results()
|
|
2193
|
+
route = respx.post(self.APIGW_URL).mock(return_value=httpx.Response(201, json={"id": "a"}))
|
|
2194
|
+
|
|
2195
|
+
self._run(
|
|
2196
|
+
tmp_path,
|
|
2197
|
+
self._result([{"source": self.SOURCE, "name": "", "type": "image/png"}]),
|
|
2198
|
+
{self.SOURCE: b"\x89PNG fake"},
|
|
2199
|
+
monkeypatch,
|
|
2200
|
+
)
|
|
2201
|
+
|
|
2202
|
+
assert self._multipart_field(route, "displayName") == self.SOURCE
|
|
2203
|
+
|
|
2204
|
+
@respx.mock
|
|
2205
|
+
def test_overlong_allure_name_is_truncated_not_dropped(
|
|
2206
|
+
self, tmp_path: Path, monkeypatch
|
|
2207
|
+
) -> None:
|
|
2208
|
+
"""The backend caps displayName at 255; a longer label must not cost the attachment."""
|
|
2209
|
+
self._mock_results()
|
|
2210
|
+
route = respx.post(self.APIGW_URL).mock(return_value=httpx.Response(201, json={"id": "a"}))
|
|
2211
|
+
|
|
2212
|
+
uploader = self._run(
|
|
2213
|
+
tmp_path,
|
|
2214
|
+
self._result([{"source": self.SOURCE, "name": "L" * 400, "type": "image/png"}]),
|
|
2215
|
+
{self.SOURCE: b"\x89PNG fake"},
|
|
2216
|
+
monkeypatch,
|
|
2217
|
+
)
|
|
2218
|
+
|
|
2219
|
+
assert uploader.summary.attachments_sent == 1
|
|
2220
|
+
assert self._multipart_field(route, "displayName") == "L" * 255
|
|
2221
|
+
|
|
2222
|
+
@respx.mock
|
|
2223
|
+
def test_step_nested_attachment_label_is_sent(self, tmp_path: Path, monkeypatch) -> None:
|
|
2224
|
+
"""Allure stores most attachments inside steps; their label must survive too."""
|
|
2225
|
+
self._mock_results()
|
|
2226
|
+
route = respx.post(self.APIGW_URL).mock(return_value=httpx.Response(201, json={"id": "a"}))
|
|
2227
|
+
|
|
2228
|
+
self._run(
|
|
2229
|
+
tmp_path,
|
|
2230
|
+
self._result([], steps=[{
|
|
2231
|
+
"name": "compare images",
|
|
2232
|
+
"attachments": [{"source": self.SOURCE, "name": "expected image",
|
|
2233
|
+
"type": "image/png"}],
|
|
2234
|
+
}]),
|
|
2235
|
+
{self.SOURCE: b"\x89PNG fake"},
|
|
2236
|
+
monkeypatch,
|
|
2237
|
+
)
|
|
2238
|
+
|
|
2239
|
+
assert self._multipart_field(route, "displayName") == "expected image"
|
|
2240
|
+
|
|
2241
|
+
@respx.mock
|
|
2242
|
+
def test_presigned_path_sends_display_name_in_presign_and_complete(
|
|
2243
|
+
self, tmp_path: Path, monkeypatch
|
|
2244
|
+
) -> None:
|
|
2245
|
+
"""Large attachments (presign -> PUT -> complete) carry the label on both JSON calls."""
|
|
2246
|
+
self._mock_results()
|
|
2247
|
+
presign = respx.post(self.PRESIGN_URL).mock(
|
|
2248
|
+
return_value=httpx.Response(201, json={
|
|
2249
|
+
"uploadUrl": self.S3_PUT_URL, "attachmentId": "att-1",
|
|
2250
|
+
"s3Key": "attachments/p/l/r/obj.png",
|
|
2251
|
+
})
|
|
2252
|
+
)
|
|
2253
|
+
respx.put(self.S3_PUT_URL).mock(return_value=httpx.Response(200))
|
|
2254
|
+
complete = respx.post(self.COMPLETE_URL).mock(
|
|
2255
|
+
return_value=httpx.Response(201, json={"attachmentId": "att-1"})
|
|
2256
|
+
)
|
|
2257
|
+
|
|
2258
|
+
uploader = self._run(
|
|
2259
|
+
tmp_path,
|
|
2260
|
+
self._result([{"source": self.SOURCE, "name": "actual image", "type": "image/png"}]),
|
|
2261
|
+
{self.SOURCE: b"y" * 4096},
|
|
2262
|
+
monkeypatch,
|
|
2263
|
+
threshold=1024,
|
|
2264
|
+
)
|
|
2265
|
+
|
|
2266
|
+
assert uploader.summary.attachments_sent == 1
|
|
2267
|
+
for route in (presign, complete):
|
|
2268
|
+
body = self._json_body(route)
|
|
2269
|
+
assert body["displayName"] == "actual image"
|
|
2270
|
+
assert body["name"] == self.SOURCE
|
|
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
|