Skip to content

Commit a4a9195

Browse files
Merge pull request #2594 from VWS-Python/fix-test-errors
Fix a couple of the current failing tests
2 parents abdc0de + ac55a64 commit a4a9195

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

src/mock_vws/_query_validators/exceptions.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def __init__(self, given_value: str) -> None:
514514
super().__init__()
515515
self.status_code = HTTPStatus.BAD_REQUEST
516516
unexpected_target_data_message = (
517-
f"Invalid value '{given_value}' in form data part "
517+
f"Invalid value '{given_value.lower()}' in form data part "
518518
"'include_target_data'. "
519519
"Expecting one of the (unquoted) string values 'all', 'none' or "
520520
"'top'."
@@ -612,10 +612,9 @@ def __init__(self) -> None:
612612
raised.
613613
"""
614614
super().__init__()
615-
self.status_code = HTTPStatus.BAD_REQUEST
615+
self.status_code = HTTPStatus.INTERNAL_SERVER_ERROR
616616
self.response_text = (
617-
"java.io.IOException: RESTEASY007550: "
618-
"Unable to get boundary for multipart"
617+
"RESTEASY007550: Unable to get boundary for multipart"
619618
)
620619

621620
date = email.utils.formatdate(
@@ -624,7 +623,7 @@ def __init__(self) -> None:
624623
usegmt=True,
625624
)
626625
self.headers = {
627-
"Content-Type": "text/html;charset=utf-8",
626+
"Content-Type": "application/json",
628627
"Connection": "keep-alive",
629628
"Server": "nginx",
630629
"Date": date,
@@ -748,17 +747,17 @@ def __init__(self) -> None:
748747
text="""\
749748
<html>
750749
<head>
751-
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
750+
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
752751
<title>Error 400 Bad Request</title>
753752
</head>
754-
<body><h2>HTTP ERROR 400 Bad Request</h2>
753+
<body>
754+
<h2>HTTP ERROR 400 Bad Request</h2>
755755
<table>
756-
<tr><th>URI:</th><td>/v1/query</td></tr>
756+
<tr><th>URI:</th><td>http://cloudreco.vuforia.com/v1/query</td></tr>
757757
<tr><th>STATUS:</th><td>400</td></tr>
758758
<tr><th>MESSAGE:</th><td>Bad Request</td></tr>
759-
<tr><th>SERVLET:</th><td>Resteasy</td></tr>
760759
</table>
761-
<hr><a href="https://eclipse.org/jetty">Powered by Jetty:// 9.4.43.v20210629</a><hr/>
760+
<hr/><a href="https://jetty.org/">Powered by Jetty:// 12.0.16</a><hr/>
762761
763762
</body>
764763
</html>

tests/mock_vws/test_query.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@
5555
text="""\
5656
<html>
5757
<head>
58-
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
58+
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
5959
<title>Error 400 Bad Request</title>
6060
</head>
61-
<body><h2>HTTP ERROR 400 Bad Request</h2>
61+
<body>
62+
<h2>HTTP ERROR 400 Bad Request</h2>
6263
<table>
63-
<tr><th>URI:</th><td>/v1/query</td></tr>
64+
<tr><th>URI:</th><td>http://cloudreco.vuforia.com/v1/query</td></tr>
6465
<tr><th>STATUS:</th><td>400</td></tr>
6566
<tr><th>MESSAGE:</th><td>Bad Request</td></tr>
66-
<tr><th>SERVLET:</th><td>Resteasy</td></tr>
6767
</table>
68-
<hr><a href="https://eclipse.org/jetty">Powered by Jetty:// 9.4.43.v20210629</a><hr/>
68+
<hr/><a href="https://jetty.org/">Powered by Jetty:// 12.0.16</a><hr/>
6969
7070
</body>
7171
</html>
72-
""", # noqa: E501
72+
""",
7373
)
7474

7575
_NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR = textwrap.dedent(
@@ -177,13 +177,10 @@ class TestContentType:
177177
),
178178
(
179179
"*/*",
180-
HTTPStatus.BAD_REQUEST,
181-
"text/html;charset=utf-8",
180+
HTTPStatus.INTERNAL_SERVER_ERROR,
181+
"application/json",
182182
None,
183-
(
184-
"java.io.IOException: RESTEASY007550: Unable to get "
185-
"boundary for multipart"
186-
),
183+
"RESTEASY007550: Unable to get boundary for multipart",
187184
),
188185
(
189186
"text/*",
@@ -255,7 +252,9 @@ def test_incorrect_no_boundary(
255252
request_body=requests_response.request.body,
256253
tell_position=requests_response.raw.tell(),
257254
)
258-
handle_server_errors(response=vws_response)
255+
256+
if resp_status_code != HTTPStatus.INTERNAL_SERVER_ERROR:
257+
handle_server_errors(response=vws_response)
259258

260259
assert requests_response.text == resp_text
261260
assert_vwq_failure(
@@ -349,7 +348,7 @@ def test_no_boundary(
349348
content_type: str,
350349
) -> None:
351350
"""
352-
If no boundary is given, a ``BAD_REQUEST`` is returned.
351+
If no boundary is given, an ``INTERNAL_SERVER_ERROR`` is returned.
353352
"""
354353
image_content = high_quality_image.getvalue()
355354
date = rfc_1123_date()
@@ -393,17 +392,12 @@ def test_no_boundary(
393392
request_body=requests_response.request.body,
394393
tell_position=requests_response.raw.tell(),
395394
)
396-
handle_server_errors(response=vws_response)
397-
398-
expected_text = (
399-
"java.io.IOException: RESTEASY007550: "
400-
"Unable to get boundary for multipart"
401-
)
395+
expected_text = "RESTEASY007550: Unable to get boundary for multipart"
402396
assert requests_response.text == expected_text
403397
assert_vwq_failure(
404398
response=vws_response,
405-
status_code=HTTPStatus.BAD_REQUEST,
406-
content_type="text/html;charset=utf-8",
399+
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
400+
content_type="application/json",
407401
cache_control=None,
408402
www_authenticate=None,
409403
connection="keep-alive",
@@ -1155,8 +1149,8 @@ def test_invalid_value(
11551149
response = _query(vuforia_database=vuforia_database, body=body)
11561150

11571151
expected_text = (
1158-
f"Invalid value '{include_target_data}' in form data "
1159-
"part 'include_target_data'. "
1152+
f"Invalid value '{str(object=include_target_data).lower()}' in "
1153+
"form data part 'include_target_data'. "
11601154
"Expecting one of the (unquoted) string values 'all', 'none' or "
11611155
"'top'."
11621156
)

0 commit comments

Comments
 (0)