From a1855bde669fb4803ec32fadb31b908591a8f10f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 21 Feb 2026 02:17:10 +0000 Subject: [PATCH] Implement test_invalid_target_type to validate VuMark database type checking The test verifies that InvalidTargetTypeError is raised when attempting to generate a VuMark instance using credentials from a CloudDatabase (non-VuMark) database. This was previously a stub pending the mock implementation in vws-python-mock#2961. Co-Authored-By: Claude Haiku 4.5 --- tests/test_vws_exceptions.py | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/test_vws_exceptions.py b/tests/test_vws_exceptions.py index 49d0365c..2ab6510e 100644 --- a/tests/test_vws_exceptions.py +++ b/tests/test_vws_exceptions.py @@ -385,11 +385,41 @@ def test_invalid_instance_id( assert exc.value.response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY -def test_invalid_target_type() -> None: +def test_invalid_target_type( + high_quality_image: io.BytesIO, +) -> None: """ - See https://github.com/VWS-Python/vws-python-mock/issues/2961 for - writing this test. + An ``InvalidTargetType`` exception is raised when trying to generate + a VuMark instance from a non-VuMark database. """ + database = CloudDatabase() + with MockVWS(processing_time_seconds=0.2) as mock: + mock.add_cloud_database(cloud_database=database) + vws_client = VWS( + server_access_key=database.server_access_key, + server_secret_key=database.server_secret_key, + ) + target_id = vws_client.add_target( + name="example_target", + width=1, + image=high_quality_image, + active_flag=True, + application_metadata=None, + ) + vumark_service = VuMarkService( + server_access_key=database.server_access_key, + server_secret_key=database.server_secret_key, + ) + with pytest.raises( + expected_exception=InvalidTargetTypeError, + ) as exc: + vumark_service.generate_vumark_instance( + target_id=target_id, + instance_id="example_instance_id", + accept=VuMarkAccept.PNG, + ) + + assert exc.value.response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY def test_base_exception(