Skip to content

Commit ae09379

Browse files
committed
Fix add_target Oops test on real Vuforia
1 parent b419167 commit ae09379

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

tests/mock_vws/test_add_target.py

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
import pytest
1313
from beartype import beartype
14-
from dirty_equals import IsInstance
1514
from vws import VWS
1615
from vws.exceptions.custom_exceptions import (
17-
OopsAnErrorOccurredPossiblyBadNameError,
16+
ServerError,
1817
)
1918
from vws.exceptions.vws_exceptions import (
2019
AuthenticationFailureError,
@@ -30,7 +29,6 @@
3029
from mock_vws._constants import ResultCodes
3130
from tests.mock_vws.utils import make_image_file
3231
from tests.mock_vws.utils.assertions import (
33-
assert_valid_date_header,
3432
assert_vws_failure,
3533
assert_vws_response,
3634
)
@@ -65,32 +63,6 @@ def _add_target_to_vws(
6563
)
6664

6765

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-
9466
def assert_success(response: Response) -> None:
9567
"""Assert that the given response is a success response for adding a
9668
target.
@@ -379,16 +351,11 @@ def test_name_invalid(
379351
}
380352

381353
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:
385358
_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)
392359

393360
assert_vws_failure(
394361
response=exc.value.response,

0 commit comments

Comments
 (0)