Skip to content

Commit a0898ac

Browse files
Merge pull request #622 from adamtheturtle/remove-unused-code
Remove untouched code [skip ci]
2 parents b3a79fc + 823e0ca commit a0898ac

File tree

2 files changed

+2
-35
lines changed

2 files changed

+2
-35
lines changed

src/mock_vws/_mock_web_query_api.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -383,40 +383,6 @@ def validate_extra_fields(
383383
return 'Unknown parameters in the request.'
384384

385385

386-
@wrapt.decorator
387-
def validate_request_body_type(
388-
wrapped: Callable[..., str],
389-
instance: Any, # pylint: disable=unused-argument
390-
args: Tuple[_RequestObjectProxy, _Context],
391-
kwargs: Dict,
392-
) -> str:
393-
"""
394-
Validate the request body type.
395-
396-
Args:
397-
wrapped: An endpoint function for `requests_mock`.
398-
instance: The class that the endpoint function is in.
399-
args: The arguments given to the endpoint function.
400-
kwargs: The keyword arguments given to the endpoint function.
401-
402-
Returns:
403-
The result of calling the endpoint.
404-
An `UNSUPPORTED_MEDIA_TYPE` response if the request body is valid UTF-8
405-
encoded text.
406-
"""
407-
request, context = args
408-
409-
try:
410-
request.body.decode('utf-8')
411-
except UnicodeDecodeError:
412-
return wrapped(*args, **kwargs)
413-
414-
text = ''
415-
context.status_code = codes.UNSUPPORTED_MEDIA_TYPE
416-
context.headers.pop('Content-Type')
417-
return text
418-
419-
420386
def route(
421387
path_pattern: str,
422388
http_methods: List[str],
@@ -453,7 +419,6 @@ def decorator(method: Callable[..., str]) -> Callable[..., str]:
453419
validate_authorization,
454420
validate_date,
455421
validate_date_header_given,
456-
validate_request_body_type,
457422
validate_include_target_data,
458423
validate_max_num_results,
459424
validate_image_field_given,

tests/mock_vws/test_unexpected_json.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def test_does_not_take_data(
8080
url = str(endpoint.prepared_request.url)
8181
netloc = urlparse(url).netloc
8282
if netloc == 'cloudreco.vuforia.com':
83+
# The multipart/formdata boundary is no longer in the given
84+
# content.
8385
assert response.text == ''
8486
assert_vwq_failure(
8587
response=response,

0 commit comments

Comments
 (0)