diff --git a/src/mock_vws/_query_validators/exceptions.py b/src/mock_vws/_query_validators/exceptions.py index 87b87390a..5f4ba2326 100644 --- a/src/mock_vws/_query_validators/exceptions.py +++ b/src/mock_vws/_query_validators/exceptions.py @@ -514,7 +514,7 @@ def __init__(self, given_value: str) -> None: 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'." @@ -612,10 +612,9 @@ def __init__(self) -> None: raised. """ super().__init__() - self.status_code = HTTPStatus.BAD_REQUEST + self.status_code = HTTPStatus.INTERNAL_SERVER_ERROR self.response_text = ( - "java.io.IOException: RESTEASY007550: " - "Unable to get boundary for multipart" + "RESTEASY007550: Unable to get boundary for multipart" ) date = email.utils.formatdate( @@ -624,7 +623,7 @@ def __init__(self) -> None: usegmt=True, ) self.headers = { - "Content-Type": "text/html;charset=utf-8", + "Content-Type": "application/json", "Connection": "keep-alive", "Server": "nginx", "Date": date, @@ -748,17 +747,17 @@ def __init__(self) -> None: text="""\ - + Error 400 Bad Request -

HTTP ERROR 400 Bad Request

+ +

HTTP ERROR 400 Bad Request

- + -
URI:/v1/query
URI:http://cloudreco.vuforia.com/v1/query
STATUS:400
MESSAGE:Bad Request
SERVLET:Resteasy
-
Powered by Jetty:// 9.4.43.v20210629
+
Powered by Jetty:// 12.0.16
diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 7da395b9b..c89b6810c 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -55,21 +55,21 @@ text="""\ - + Error 400 Bad Request -

HTTP ERROR 400 Bad Request

+ +

HTTP ERROR 400 Bad Request

- + -
URI:/v1/query
URI:http://cloudreco.vuforia.com/v1/query
STATUS:400
MESSAGE:Bad Request
SERVLET:Resteasy
-
Powered by Jetty:// 9.4.43.v20210629
+
Powered by Jetty:// 12.0.16
- """, # noqa: E501 + """, ) _NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR = textwrap.dedent( @@ -177,13 +177,10 @@ class TestContentType: ), ( "*/*", - 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/*", @@ -255,7 +252,9 @@ def test_incorrect_no_boundary( 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) assert requests_response.text == resp_text assert_vwq_failure( @@ -349,7 +348,7 @@ def test_no_boundary( 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() @@ -393,17 +392,12 @@ def test_no_boundary( 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" 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", @@ -1155,8 +1149,8 @@ def test_invalid_value( 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'." )