From 9c3346765730b1fe1475271fa674efc43db6d45c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 18 Feb 2026 15:14:19 +0000 Subject: [PATCH 1/2] 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 --- tests/mock_vws/test_vumark_generation_api.py | 81 +++++++++++--------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/tests/mock_vws/test_vumark_generation_api.py b/tests/mock_vws/test_vumark_generation_api.py index ac7b2634a..2cb0abda3 100644 --- a/tests/mock_vws/test_vumark_generation_api.py +++ b/tests/mock_vws/test_vumark_generation_api.py @@ -15,41 +15,46 @@ @pytest.mark.usefixtures("verify_mock_vuforia") -def test_generate_instance_success( - vumark_vuforia_database: VuMarkVuforiaDatabase, -) -> None: - """A VuMark instance can be generated with valid template settings.""" - request_path = f"/targets/{vumark_vuforia_database.target_id}/instances" - content_type = "application/json" - generated_instance_id = uuid4().hex - content = json.dumps(obj={"instance_id": generated_instance_id}).encode( - encoding="utf-8" - ) - date = rfc_1123_date() - authorization_string = authorization_header( - access_key=vumark_vuforia_database.server_access_key, - secret_key=vumark_vuforia_database.server_secret_key, - method=HTTPMethod.POST, - content=content, - content_type=content_type, - date=date, - request_path=request_path, - ) - - response = requests.post( - url=_VWS_HOST + request_path, - headers={ - "Accept": "image/png", - "Authorization": authorization_string, - "Content-Length": str(object=len(content)), - "Content-Type": content_type, - "Date": date, - }, - data=content, - timeout=30, - ) - - assert response.status_code == HTTPStatus.OK - assert response.headers["Content-Type"].split(sep=";")[0] == "image/png" - assert response.content.startswith(_PNG_SIGNATURE) - assert len(response.content) > len(_PNG_SIGNATURE) +class TestGenerateInstance: + """Tests for the VuMark instance generation endpoint.""" + + def test_generate_instance_success( + self, + vumark_vuforia_database: VuMarkVuforiaDatabase, + ) -> None: + """A VuMark instance can be generated with valid template settings.""" + target_id = vumark_vuforia_database.target_id + request_path = f"/targets/{target_id}/instances" + content_type = "application/json" + generated_instance_id = uuid4().hex + body_dict = {"instance_id": generated_instance_id} + content = json.dumps(obj=body_dict).encode(encoding="utf-8") + date = rfc_1123_date() + authorization_string = authorization_header( + access_key=vumark_vuforia_database.server_access_key, + secret_key=vumark_vuforia_database.server_secret_key, + method=HTTPMethod.POST, + content=content, + content_type=content_type, + date=date, + request_path=request_path, + ) + + response = requests.post( + url=_VWS_HOST + request_path, + headers={ + "Accept": "image/png", + "Authorization": authorization_string, + "Content-Length": str(object=len(content)), + "Content-Type": content_type, + "Date": date, + }, + data=content, + timeout=30, + ) + + assert response.status_code == HTTPStatus.OK + content_type_value = response.headers["Content-Type"].split(sep=";")[0] + assert content_type_value == "image/png" + assert response.content.startswith(_PNG_SIGNATURE) + assert len(response.content) > len(_PNG_SIGNATURE) From 74340acb09592b8f71a25603137e8f349f4f538d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 18 Feb 2026 15:26:38 +0000 Subject: [PATCH 2/2] Make test_generate_instance_success a static method Co-Authored-By: Claude Sonnet 4.6 --- tests/mock_vws/test_vumark_generation_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mock_vws/test_vumark_generation_api.py b/tests/mock_vws/test_vumark_generation_api.py index 2cb0abda3..f2ec64527 100644 --- a/tests/mock_vws/test_vumark_generation_api.py +++ b/tests/mock_vws/test_vumark_generation_api.py @@ -18,8 +18,8 @@ class TestGenerateInstance: """Tests for the VuMark instance generation endpoint.""" + @staticmethod def test_generate_instance_success( - self, vumark_vuforia_database: VuMarkVuforiaDatabase, ) -> None: """A VuMark instance can be generated with valid template settings."""