Skip to content

Commit 40bd318

Browse files
Group VuMark generation tests in class (#2957)
* Group VuMark generation tests in TestGenerateInstance class Move test_generate_instance_success into a TestGenerateInstance class and apply the @pytest.mark.usefixtures decorator at the class level to reduce duplication. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * Make test_generate_instance_success a static method Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 215912a commit 40bd318

1 file changed

Lines changed: 43 additions & 38 deletions

File tree

tests/mock_vws/test_vumark_generation_api.py

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,46 @@
1515

1616

1717
@pytest.mark.usefixtures("verify_mock_vuforia")
18-
def test_generate_instance_success(
19-
vumark_vuforia_database: VuMarkVuforiaDatabase,
20-
) -> None:
21-
"""A VuMark instance can be generated with valid template settings."""
22-
request_path = f"/targets/{vumark_vuforia_database.target_id}/instances"
23-
content_type = "application/json"
24-
generated_instance_id = uuid4().hex
25-
content = json.dumps(obj={"instance_id": generated_instance_id}).encode(
26-
encoding="utf-8"
27-
)
28-
date = rfc_1123_date()
29-
authorization_string = authorization_header(
30-
access_key=vumark_vuforia_database.server_access_key,
31-
secret_key=vumark_vuforia_database.server_secret_key,
32-
method=HTTPMethod.POST,
33-
content=content,
34-
content_type=content_type,
35-
date=date,
36-
request_path=request_path,
37-
)
38-
39-
response = requests.post(
40-
url=_VWS_HOST + request_path,
41-
headers={
42-
"Accept": "image/png",
43-
"Authorization": authorization_string,
44-
"Content-Length": str(object=len(content)),
45-
"Content-Type": content_type,
46-
"Date": date,
47-
},
48-
data=content,
49-
timeout=30,
50-
)
51-
52-
assert response.status_code == HTTPStatus.OK
53-
assert response.headers["Content-Type"].split(sep=";")[0] == "image/png"
54-
assert response.content.startswith(_PNG_SIGNATURE)
55-
assert len(response.content) > len(_PNG_SIGNATURE)
18+
class TestGenerateInstance:
19+
"""Tests for the VuMark instance generation endpoint."""
20+
21+
@staticmethod
22+
def test_generate_instance_success(
23+
vumark_vuforia_database: VuMarkVuforiaDatabase,
24+
) -> None:
25+
"""A VuMark instance can be generated with valid template settings."""
26+
target_id = vumark_vuforia_database.target_id
27+
request_path = f"/targets/{target_id}/instances"
28+
content_type = "application/json"
29+
generated_instance_id = uuid4().hex
30+
body_dict = {"instance_id": generated_instance_id}
31+
content = json.dumps(obj=body_dict).encode(encoding="utf-8")
32+
date = rfc_1123_date()
33+
authorization_string = authorization_header(
34+
access_key=vumark_vuforia_database.server_access_key,
35+
secret_key=vumark_vuforia_database.server_secret_key,
36+
method=HTTPMethod.POST,
37+
content=content,
38+
content_type=content_type,
39+
date=date,
40+
request_path=request_path,
41+
)
42+
43+
response = requests.post(
44+
url=_VWS_HOST + request_path,
45+
headers={
46+
"Accept": "image/png",
47+
"Authorization": authorization_string,
48+
"Content-Length": str(object=len(content)),
49+
"Content-Type": content_type,
50+
"Date": date,
51+
},
52+
data=content,
53+
timeout=30,
54+
)
55+
56+
assert response.status_code == HTTPStatus.OK
57+
content_type_value = response.headers["Content-Type"].split(sep=";")[0]
58+
assert content_type_value == "image/png"
59+
assert response.content.startswith(_PNG_SIGNATURE)
60+
assert len(response.content) > len(_PNG_SIGNATURE)

0 commit comments

Comments
 (0)