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
2 changes: 1 addition & 1 deletion src/vws/exceptions/vws_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class TargetNameExistError(VWSError):
def target_name(self) -> str:
"""The target name which already exists."""
response_body = self.response.request_body
if not isinstance(response_body, str | bytes): # pragma: no cover
if not isinstance(response_body, str | bytes):
msg = "A target-name error response must have a request body."
raise TypeError(msg)
request_json = json_object(value=response_body)
Expand Down
20 changes: 20 additions & 0 deletions tests/test_vws_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,26 @@ def test_target_name_exist(
assert exc.value.target_name == "x"


def test_target_name_exist_requires_request_body() -> None:
"""A target-name error without a request body is rejected."""
response = Response(
text="",
url="https://vws.vuforia.com/targets",
status_code=HTTPStatus.FORBIDDEN,
headers={},
request_body=None,
tell_position=0,
content=b"",
)
error = TargetNameExistError(response=response)

with pytest.raises(
expected_exception=TypeError,
match="must have a request body",
):
_ = error.target_name


def test_project_inactive(
high_quality_image: io.BytesIO,
) -> None:
Expand Down