Skip to content

Commit f34b270

Browse files
committed
Remove one more use of a custom helper
1 parent 2980360 commit f34b270

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

tests/mock_vws/test_add_target.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
ImageTooLarge,
2525
MetadataTooLarge,
2626
ProjectInactive,
27+
TargetNameExist,
2728
)
2829
from vws_auth_tools import authorization_header, rfc_1123_date
2930

@@ -417,32 +418,30 @@ def test_name_invalid(
417418
@staticmethod
418419
def test_existing_target_name(
419420
image_file_failed_state: io.BytesIO,
420-
vuforia_database: VuforiaDatabase,
421+
vws_client: VWS,
421422
) -> None:
422423
"""
423424
Only one target can have a given name.
424425
"""
425-
image_data = image_file_failed_state.read()
426-
image_data_encoded = base64.b64encode(s=image_data).decode("ascii")
427-
428-
data = {
429-
"name": "example_name",
430-
"width": 1,
431-
"image": image_data_encoded,
432-
}
433-
434-
_add_target_to_vws(
435-
vuforia_database=vuforia_database,
436-
data=data,
426+
vws_client.add_target(
427+
name="example_name",
428+
width=1,
429+
image=image_file_failed_state,
430+
application_metadata=None,
431+
active_flag=True,
437432
)
438433

439-
response = _add_target_to_vws(
440-
vuforia_database=vuforia_database,
441-
data=data,
442-
)
434+
with pytest.raises(expected_exception=TargetNameExist) as exc:
435+
vws_client.add_target(
436+
name="example_name",
437+
width=1,
438+
image=image_file_failed_state,
439+
application_metadata=None,
440+
active_flag=True,
441+
)
443442

444443
assert_vws_failure(
445-
response=response,
444+
response=exc.value.response,
446445
status_code=HTTPStatus.FORBIDDEN,
447446
result_code=ResultCodes.TARGET_NAME_EXIST,
448447
)

0 commit comments

Comments
 (0)