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'
@@ -228,6 +239,7 @@ def test_incorrect_no_boundary(
228239 content_type = resp_content_type ,
229240 cache_control = resp_cache_control ,
230241 www_authenticate = None ,
242+ connection = 'keep-alive' ,
231243 )
232244
233245 def test_incorrect_with_boundary (
@@ -284,6 +296,7 @@ def test_incorrect_with_boundary(
284296 content_type = None ,
285297 cache_control = None ,
286298 www_authenticate = None ,
299+ connection = 'keep-alive' ,
287300 )
288301
289302 @pytest .mark .parametrize (
@@ -347,6 +360,7 @@ def test_no_boundary(
347360 content_type = 'text/html;charset=utf-8' ,
348361 cache_control = None ,
349362 www_authenticate = None ,
363+ connection = 'keep-alive' ,
350364 )
351365
352366 def test_bogus_boundary (
@@ -398,6 +412,7 @@ def test_bogus_boundary(
398412 content_type = 'application/json' ,
399413 cache_control = None ,
400414 www_authenticate = None ,
415+ connection = 'keep-alive' ,
401416 )
402417
403418 def test_extra_section (
@@ -590,6 +605,7 @@ def test_missing_image(
590605 content_type = 'application/json' ,
591606 cache_control = None ,
592607 www_authenticate = None ,
608+ connection = 'keep-alive' ,
593609 )
594610
595611 def test_extra_fields (
@@ -615,6 +631,7 @@ def test_extra_fields(
615631 status_code = HTTPStatus .BAD_REQUEST ,
616632 cache_control = None ,
617633 www_authenticate = None ,
634+ connection = 'keep-alive' ,
618635 )
619636
620637 def test_missing_image_and_extra_fields (
@@ -640,6 +657,7 @@ def test_missing_image_and_extra_fields(
640657 status_code = HTTPStatus .BAD_REQUEST ,
641658 cache_control = None ,
642659 www_authenticate = None ,
660+ connection = 'keep-alive' ,
643661 )
644662
645663
@@ -778,6 +796,7 @@ def test_out_of_range(
778796 status_code = HTTPStatus .BAD_REQUEST ,
779797 cache_control = None ,
780798 www_authenticate = None ,
799+ connection = 'keep-alive' ,
781800 )
782801
783802 @pytest .mark .parametrize (
@@ -816,6 +835,7 @@ def test_invalid_type(
816835 status_code = HTTPStatus .BAD_REQUEST ,
817836 cache_control = None ,
818837 www_authenticate = None ,
838+ connection = 'keep-alive' ,
819839 )
820840
821841
@@ -999,6 +1019,7 @@ def test_invalid_value(
9991019 content_type = 'application/json' ,
10001020 cache_control = None ,
10011021 www_authenticate = None ,
1022+ connection = 'keep-alive' ,
10021023 )
10031024
10041025
@@ -1111,6 +1132,7 @@ def test_invalid(
11111132 content_type = None ,
11121133 cache_control = None ,
11131134 www_authenticate = None ,
1135+ connection = 'keep-alive' ,
11141136 )
11151137
11161138
@@ -1189,6 +1211,7 @@ def test_not_image(
11891211 content_type = 'application/json' ,
11901212 cache_control = None ,
11911213 www_authenticate = None ,
1214+ connection = 'keep-alive' ,
11921215 )
11931216 assert response .json ().keys () == {'transaction_id' , 'result_code' }
11941217 assert_valid_transaction_id (response = response )
@@ -1221,7 +1244,7 @@ def test_png(
12211244 https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query.
12221245 the maximum file size is "2MiB for PNG".
12231246
1224- Above this limit, a ``ConnectionError `` is raised .
1247+ Above this limit, a ``REQUEST_ENTITY_TOO_LARGE `` response is returned .
12251248 We do not test exactly at this limit, but that may be beneficial in the
12261249 future.
12271250 """
@@ -1271,11 +1294,20 @@ def test_png(
12711294 assert image_content_size > max_bytes
12721295 assert (image_content_size * 0.95 ) < max_bytes
12731296
1274- with pytest .raises (requests .exceptions .ConnectionError ):
1275- query (
1276- vuforia_database = vuforia_database ,
1277- body = body ,
1278- )
1297+ response = query (
1298+ vuforia_database = vuforia_database ,
1299+ body = body ,
1300+ )
1301+
1302+ assert_vwq_failure (
1303+ response = response ,
1304+ status_code = HTTPStatus .REQUEST_ENTITY_TOO_LARGE ,
1305+ content_type = 'text/html' ,
1306+ cache_control = None ,
1307+ www_authenticate = None ,
1308+ connection = 'Close' ,
1309+ )
1310+ assert response .text == _NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR
12791311
12801312 def test_jpeg (
12811313 self ,
@@ -1287,7 +1319,7 @@ def test_jpeg(
12871319 the maximum file size is "512 KiB for JPEG".
12881320 However, this test shows that the maximum size for JPEG is 2 MiB.
12891321
1290- Above this limit, a ``ConnectionError `` is raised .
1322+ Above this limit, a ``REQUEST_ENTITY_TOO_LARGE `` response is returned .
12911323 We do not test exactly at this limit, but that may be beneficial in the
12921324 future.
12931325 """
@@ -1336,11 +1368,21 @@ def test_jpeg(
13361368 assert image_content_size > max_bytes
13371369 assert (image_content_size * 0.95 ) < max_bytes
13381370
1339- with pytest .raises (requests .exceptions .ConnectionError ):
1340- query (
1341- vuforia_database = vuforia_database ,
1342- body = body ,
1343- )
1371+ response = query (
1372+ vuforia_database = vuforia_database ,
1373+ body = body ,
1374+ )
1375+
1376+ assert_vwq_failure (
1377+ response = response ,
1378+ status_code = HTTPStatus .REQUEST_ENTITY_TOO_LARGE ,
1379+ content_type = 'text/html' ,
1380+ cache_control = None ,
1381+ www_authenticate = None ,
1382+ connection = 'Close' ,
1383+ )
1384+
1385+ assert response .text == _NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR
13441386
13451387
13461388@pytest .mark .usefixtures ('verify_mock_vuforia' )
@@ -1391,6 +1433,7 @@ def test_max_height(self, vuforia_database: VuforiaDatabase) -> None:
13911433 content_type = 'application/json' ,
13921434 cache_control = None ,
13931435 www_authenticate = None ,
1436+ connection = 'keep-alive' ,
13941437 )
13951438 assert response .json ().keys () == {'transaction_id' , 'result_code' }
13961439 assert_valid_transaction_id (response = response )
@@ -1449,6 +1492,7 @@ def test_max_width(self, vuforia_database: VuforiaDatabase) -> None:
14491492 content_type = 'application/json' ,
14501493 cache_control = None ,
14511494 www_authenticate = None ,
1495+ connection = 'keep-alive' ,
14521496 )
14531497 assert response .json ().keys () == {'transaction_id' , 'result_code' }
14541498 assert_valid_transaction_id (response = response )
@@ -1518,6 +1562,7 @@ def test_unsupported(
15181562 content_type = 'application/json' ,
15191563 cache_control = None ,
15201564 www_authenticate = None ,
1565+ connection = 'keep-alive' ,
15211566 )
15221567 assert response .json ().keys () == {'transaction_id' , 'result_code' }
15231568 assert_valid_transaction_id (response = response )
@@ -1716,6 +1761,7 @@ def test_deleted(
17161761 status_code = HTTPStatus .INTERNAL_SERVER_ERROR ,
17171762 cache_control = 'must-revalidate,no-cache,no-store' ,
17181763 www_authenticate = None ,
1764+ connection = 'keep-alive' ,
17191765 )
17201766
17211767 return
@@ -1955,6 +2001,7 @@ def test_inactive_project(
19552001 content_type = 'application/json' ,
19562002 cache_control = None ,
19572003 www_authenticate = None ,
2004+ connection = 'keep-alive' ,
19582005 )
19592006 assert response .json ().keys () == {'transaction_id' , 'result_code' }
19602007 assert_valid_transaction_id (response = response )
0 commit comments