|
24 | 24 | ImageTooLarge, |
25 | 25 | MetadataTooLarge, |
26 | 26 | ProjectInactive, |
| 27 | + TargetNameExist, |
27 | 28 | ) |
28 | 29 | from vws_auth_tools import authorization_header, rfc_1123_date |
29 | 30 |
|
@@ -417,32 +418,30 @@ def test_name_invalid( |
417 | 418 | @staticmethod |
418 | 419 | def test_existing_target_name( |
419 | 420 | image_file_failed_state: io.BytesIO, |
420 | | - vuforia_database: VuforiaDatabase, |
| 421 | + vws_client: VWS, |
421 | 422 | ) -> None: |
422 | 423 | """ |
423 | 424 | Only one target can have a given name. |
424 | 425 | """ |
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, |
437 | 432 | ) |
438 | 433 |
|
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 | + ) |
443 | 442 |
|
444 | 443 | assert_vws_failure( |
445 | | - response=response, |
| 444 | + response=exc.value.response, |
446 | 445 | status_code=HTTPStatus.FORBIDDEN, |
447 | 446 | result_code=ResultCodes.TARGET_NAME_EXIST, |
448 | 447 | ) |
|
0 commit comments