|
11 | 11 |
|
12 | 12 | import pytest
|
13 | 13 | from beartype import beartype
|
14 |
| -from dirty_equals import IsInstance |
15 | 14 | from vws import VWS
|
16 | 15 | from vws.exceptions.custom_exceptions import (
|
17 |
| - OopsAnErrorOccurredPossiblyBadNameError, |
| 16 | + ServerError, |
18 | 17 | )
|
19 | 18 | from vws.exceptions.vws_exceptions import (
|
20 | 19 | AuthenticationFailureError,
|
|
30 | 29 | from mock_vws._constants import ResultCodes
|
31 | 30 | from tests.mock_vws.utils import make_image_file
|
32 | 31 | from tests.mock_vws.utils.assertions import (
|
33 |
| - assert_valid_date_header, |
34 | 32 | assert_vws_failure,
|
35 | 33 | assert_vws_response,
|
36 | 34 | )
|
@@ -65,32 +63,6 @@ def _add_target_to_vws(
|
65 | 63 | )
|
66 | 64 |
|
67 | 65 |
|
68 |
| -@beartype |
69 |
| -def _assert_oops_response(response: Response) -> None: |
70 |
| - """Assert that the response is in the format of Vuforia's "Oops, an error |
71 |
| - occurred" HTML response. |
72 |
| -
|
73 |
| - Raises: |
74 |
| - AssertionError: The given response is not expected format. |
75 |
| - """ |
76 |
| - assert_valid_date_header(response=response) |
77 |
| - assert "Oops, an error occurred" in response.text |
78 |
| - assert "This exception has been logged with id" in response.text |
79 |
| - |
80 |
| - expected_headers = { |
81 |
| - "Connection": "keep-alive", |
82 |
| - "Content-Type": "text/html; charset=UTF-8", |
83 |
| - "Date": response.headers["Date"], |
84 |
| - "server": "envoy", |
85 |
| - "Content-Length": "1190", |
86 |
| - "x-envoy-upstream-service-time": IsInstance(expected_type=str), |
87 |
| - "strict-transport-security": "max-age=31536000", |
88 |
| - "x-aws-region": IsInstance(expected_type=str), |
89 |
| - "x-content-type-options": "nosniff", |
90 |
| - } |
91 |
| - assert response.headers == expected_headers |
92 |
| - |
93 |
| - |
94 | 66 | def assert_success(response: Response) -> None:
|
95 | 67 | """Assert that the given response is a success response for adding a
|
96 | 68 | target.
|
@@ -379,16 +351,11 @@ def test_name_invalid(
|
379 | 351 | }
|
380 | 352 |
|
381 | 353 | if status_code == HTTPStatus.INTERNAL_SERVER_ERROR:
|
382 |
| - with pytest.raises( |
383 |
| - expected_exception=OopsAnErrorOccurredPossiblyBadNameError, |
384 |
| - ) as oops_exc: |
| 354 | + with pytest.raises(expected_exception=ServerError) as exc: |
| 355 | + _add_target_to_vws(vws_client=vws_client, data=data) |
| 356 | + else: |
| 357 | + with pytest.raises(expected_exception=FailError) as exc: |
385 | 358 | _add_target_to_vws(vws_client=vws_client, data=data)
|
386 |
| - assert oops_exc.value.response.status_code == status_code |
387 |
| - _assert_oops_response(response=oops_exc.value.response) |
388 |
| - return |
389 |
| - |
390 |
| - with pytest.raises(expected_exception=FailError) as exc: |
391 |
| - _add_target_to_vws(vws_client=vws_client, data=data) |
392 | 359 |
|
393 | 360 | assert_vws_failure(
|
394 | 361 | response=exc.value.response,
|
|
0 commit comments