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
19 changes: 9 additions & 10 deletions src/mock_vws/_query_validators/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
super().__init__()
self.status_code = HTTPStatus.BAD_REQUEST
unexpected_target_data_message = (
f"Invalid value '{given_value}' in form data part "
f"Invalid value '{given_value.lower()}' in form data part "
"'include_target_data'. "
"Expecting one of the (unquoted) string values 'all', 'none' or "
"'top'."
Expand Down Expand Up @@ -612,10 +612,9 @@
raised.
"""
super().__init__()
self.status_code = HTTPStatus.BAD_REQUEST
self.status_code = HTTPStatus.INTERNAL_SERVER_ERROR

Check warning on line 615 in src/mock_vws/_query_validators/exceptions.py

View check run for this annotation

Codecov / codecov/patch

src/mock_vws/_query_validators/exceptions.py#L615

Added line #L615 was not covered by tests
self.response_text = (
"java.io.IOException: RESTEASY007550: "
"Unable to get boundary for multipart"
"RESTEASY007550: Unable to get boundary for multipart"
)

date = email.utils.formatdate(
Expand All @@ -624,7 +623,7 @@
usegmt=True,
)
self.headers = {
"Content-Type": "text/html;charset=utf-8",
"Content-Type": "application/json",
"Connection": "keep-alive",
"Server": "nginx",
"Date": date,
Expand Down Expand Up @@ -748,17 +747,17 @@
text="""\
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 400 Bad Request</title>
</head>
<body><h2>HTTP ERROR 400 Bad Request</h2>
<body>
<h2>HTTP ERROR 400 Bad Request</h2>
<table>
<tr><th>URI:</th><td>/v1/query</td></tr>
<tr><th>URI:</th><td>http://cloudreco.vuforia.com/v1/query</td></tr>
<tr><th>STATUS:</th><td>400</td></tr>
<tr><th>MESSAGE:</th><td>Bad Request</td></tr>
<tr><th>SERVLET:</th><td>Resteasy</td></tr>
</table>
<hr><a href="https://eclipse.org/jetty">Powered by Jetty:// 9.4.43.v20210629</a><hr/>
<hr/><a href="https://jetty.org/">Powered by Jetty:// 12.0.16</a><hr/>

</body>
</html>
Expand Down
42 changes: 18 additions & 24 deletions tests/mock_vws/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@
text="""\
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 400 Bad Request</title>
</head>
<body><h2>HTTP ERROR 400 Bad Request</h2>
<body>
<h2>HTTP ERROR 400 Bad Request</h2>
<table>
<tr><th>URI:</th><td>/v1/query</td></tr>
<tr><th>URI:</th><td>http://cloudreco.vuforia.com/v1/query</td></tr>
<tr><th>STATUS:</th><td>400</td></tr>
<tr><th>MESSAGE:</th><td>Bad Request</td></tr>
<tr><th>SERVLET:</th><td>Resteasy</td></tr>
</table>
<hr><a href="https://eclipse.org/jetty">Powered by Jetty:// 9.4.43.v20210629</a><hr/>
<hr/><a href="https://jetty.org/">Powered by Jetty:// 12.0.16</a><hr/>

</body>
</html>
""", # noqa: E501
""",
)

_NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR = textwrap.dedent(
Expand Down Expand Up @@ -177,13 +177,10 @@
),
(
"*/*",
HTTPStatus.BAD_REQUEST,
"text/html;charset=utf-8",
HTTPStatus.INTERNAL_SERVER_ERROR,
"application/json",
None,
(
"java.io.IOException: RESTEASY007550: Unable to get "
"boundary for multipart"
),
"RESTEASY007550: Unable to get boundary for multipart",
),
(
"text/*",
Expand Down Expand Up @@ -255,7 +252,9 @@
request_body=requests_response.request.body,
tell_position=requests_response.raw.tell(),
)
handle_server_errors(response=vws_response)

if resp_status_code != HTTPStatus.INTERNAL_SERVER_ERROR:
handle_server_errors(response=vws_response)

Check warning on line 257 in tests/mock_vws/test_query.py

View check run for this annotation

Codecov / codecov/patch

tests/mock_vws/test_query.py#L257

Added line #L257 was not covered by tests

assert requests_response.text == resp_text
assert_vwq_failure(
Expand Down Expand Up @@ -349,7 +348,7 @@
content_type: str,
) -> None:
"""
If no boundary is given, a ``BAD_REQUEST`` is returned.
If no boundary is given, an ``INTERNAL_SERVER_ERROR`` is returned.
"""
image_content = high_quality_image.getvalue()
date = rfc_1123_date()
Expand Down Expand Up @@ -393,17 +392,12 @@
request_body=requests_response.request.body,
tell_position=requests_response.raw.tell(),
)
handle_server_errors(response=vws_response)

expected_text = (
"java.io.IOException: RESTEASY007550: "
"Unable to get boundary for multipart"
)
expected_text = "RESTEASY007550: Unable to get boundary for multipart"

Check warning on line 395 in tests/mock_vws/test_query.py

View check run for this annotation

Codecov / codecov/patch

tests/mock_vws/test_query.py#L395

Added line #L395 was not covered by tests
assert requests_response.text == expected_text
assert_vwq_failure(
response=vws_response,
status_code=HTTPStatus.BAD_REQUEST,
content_type="text/html;charset=utf-8",
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
content_type="application/json",
cache_control=None,
www_authenticate=None,
connection="keep-alive",
Expand Down Expand Up @@ -1155,8 +1149,8 @@
response = _query(vuforia_database=vuforia_database, body=body)

expected_text = (
f"Invalid value '{include_target_data}' in form data "
"part 'include_target_data'. "
f"Invalid value '{str(object=include_target_data).lower()}' in "
"form data part 'include_target_data'. "
"Expecting one of the (unquoted) string values 'all', 'none' or "
"'top'."
)
Expand Down