Skip to content

Commit d6aa76a

Browse files
committed
Test the entity too large text
1 parent decbb6c commit d6aa76a

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/mock_vws/_query_validators/exceptions.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,17 @@ def __init__(self) -> None:
636636
"""
637637
super().__init__()
638638
self.status_code = HTTPStatus.REQUEST_ENTITY_TOO_LARGE
639-
# TODO assert this!
640-
self.response_text = ''
639+
self.response_text = textwrap.dedent(
640+
"""\
641+
<html>\r
642+
<head><title>413 Request Entity Too Large</title></head>\r
643+
<body bgcolor="white">\r
644+
<center><h1>413 Request Entity Too Large</h1></center>\r
645+
<hr><center>nginx</center>\r
646+
</body>\r
647+
</html>\r
648+
""",
649+
)
641650
date = email.utils.formatdate(None, localtime=False, usegmt=True)
642651
self.headers = {
643652
'Connection': 'Close',

src/mock_vws/_query_validators/image_validators.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import io
77
from typing import Dict
88

9-
import requests
109
from PIL import Image
1110

12-
from mock_vws._query_validators.exceptions import BadImage, ImageNotGiven, RequestEntityTooLarge
11+
from mock_vws._query_validators.exceptions import (
12+
BadImage,
13+
ImageNotGiven,
14+
RequestEntityTooLarge,
15+
)
1316

1417

1518
def validate_image_field_given(

tests/mock_vws/test_query.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@
6262
""", # noqa: E501
6363
)
6464

65+
_NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR = textwrap.dedent(
66+
"""\
67+
<html>\r
68+
<head><title>413 Request Entity Too Large</title></head>\r
69+
<body bgcolor="white">\r
70+
<center><h1>413 Request Entity Too Large</h1></center>\r
71+
<hr><center>nginx</center>\r
72+
</body>\r
73+
</html>\r
74+
""",
75+
)
6576

6677
_JETTY_ERROR_DELETION_NOT_COMPLETE_START_PATH = (
6778
Path(__file__).parent / 'jetty_error_deletion_not_complete.html'
@@ -1296,6 +1307,7 @@ def test_png(
12961307
www_authenticate=None,
12971308
connection='Close',
12981309
)
1310+
assert response.text == _NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR
12991311

13001312
def test_jpeg(
13011313
self,
@@ -1370,6 +1382,8 @@ def test_jpeg(
13701382
connection='Close',
13711383
)
13721384

1385+
assert response.text == _NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR
1386+
13731387

13741388
@pytest.mark.usefixtures('verify_mock_vuforia')
13751389
class TestMaximumImageDimensions:

0 commit comments

Comments
 (0)