Skip to content

Commit a1855bd

Browse files
adamtheturtleclaude
andcommitted
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 <noreply@anthropic.com>
1 parent bf64c7f commit a1855bd

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

tests/test_vws_exceptions.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,41 @@ def test_invalid_instance_id(
385385
assert exc.value.response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY
386386

387387

388-
def test_invalid_target_type() -> None:
388+
def test_invalid_target_type(
389+
high_quality_image: io.BytesIO,
390+
) -> None:
389391
"""
390-
See https://github.com/VWS-Python/vws-python-mock/issues/2961 for
391-
writing this test.
392+
An ``InvalidTargetType`` exception is raised when trying to generate
393+
a VuMark instance from a non-VuMark database.
392394
"""
395+
database = CloudDatabase()
396+
with MockVWS(processing_time_seconds=0.2) as mock:
397+
mock.add_cloud_database(cloud_database=database)
398+
vws_client = VWS(
399+
server_access_key=database.server_access_key,
400+
server_secret_key=database.server_secret_key,
401+
)
402+
target_id = vws_client.add_target(
403+
name="example_target",
404+
width=1,
405+
image=high_quality_image,
406+
active_flag=True,
407+
application_metadata=None,
408+
)
409+
vumark_service = VuMarkService(
410+
server_access_key=database.server_access_key,
411+
server_secret_key=database.server_secret_key,
412+
)
413+
with pytest.raises(
414+
expected_exception=InvalidTargetTypeError,
415+
) as exc:
416+
vumark_service.generate_vumark_instance(
417+
target_id=target_id,
418+
instance_id="example_instance_id",
419+
accept=VuMarkAccept.PNG,
420+
)
421+
422+
assert exc.value.response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY
393423

394424

395425
def test_base_exception(

0 commit comments

Comments
 (0)