Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/mock_vws/test_invalid_given_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def test_not_real_id(
target ID
of a target which does not exist.
"""
# This shared check only covers endpoints that end in target_id,
# such as /targets/{target_id}. Endpoints with trailing segments
# are covered by endpoint-specific tests.
if not endpoint.path_url.endswith(target_id):
return

Expand Down
17 changes: 17 additions & 0 deletions tests/mock_vws/test_vumark_generation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ def test_empty_instance_id(
== ResultCodes.INVALID_INSTANCE_ID.value
)

@staticmethod
def test_unknown_target(
vumark_vuforia_database: VuMarkCloudDatabase,
) -> None:
"""An unknown target_id returns UnknownTarget."""
response = _make_vumark_request(
server_access_key=vumark_vuforia_database.server_access_key,
server_secret_key=vumark_vuforia_database.server_secret_key,
target_id=uuid4().hex,
instance_id=uuid4().hex,
accept=VuMarkAccept.PNG,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum passed to str-typed beartype-checked parameter

Low Severity

VuMarkAccept.PNG is passed as the accept argument to _make_vumark_request, which declares accept: str and is decorated with @beartype. Every other caller of _make_vumark_request in this file passes a plain MIME-type string like "image/png". If VuMarkAccept is not a str subclass (i.e., not a StrEnum), beartype will reject the call at runtime, causing the test to fail with a type violation rather than actually exercising the unknown-target code path.

Fix in Cursor Fix in Web

)

assert response.status_code == HTTPStatus.NOT_FOUND
response_json = response.json()
assert response_json["result_code"] == ResultCodes.UNKNOWN_TARGET.value

@staticmethod
def test_non_vumark_database(
vuforia_database: CloudDatabase,
Expand Down