@@ -59,22 +59,26 @@ def _get_config_file_name(self) -> str:
59
59
self .delete_config_file = True
60
60
return config_file .name
61
61
62
- def test_payload_exceeds_max_request_size_evaluate (self ):
62
+ def create_large_payload (self ):
63
63
size_mb = 2
64
64
num_chars = size_mb * 1024 * 1024
65
65
large_string = string .printable * (num_chars // len (string .printable ))
66
66
large_string += string .printable [:num_chars % len (string .printable )]
67
-
68
67
payload = {
69
68
"data" : { "_arg1" : large_string },
70
69
"script" : "return _arg1"
71
70
}
72
- headers = {
73
- "Content-Type" : "application/json" ,
74
- }
71
+ return json .dumps (payload ).encode ('utf-8' )
72
+
73
+ def test_payload_exceeds_max_request_size_evaluate (self ):
74
+ headers = { "Content-Type" : "application/json" }
75
75
url = self ._get_url () + "/evaluate"
76
- response = requests .request ("POST" , url , data = json .dumps (payload ).encode ('utf-8' ),
77
- headers = headers )
78
- result = json .loads (response .text )
76
+ response = requests .post (url , data = self .create_large_payload (), headers = headers )
77
+ self .assertEqual (413 , response .status_code )
78
+
79
+ def test_payload_exceeds_max_request_size_query (self ):
80
+ headers = { "Content-Type" : "application/json" }
81
+ url = self ._get_url () + "/query/model_name"
82
+ response = requests .post (url , data = self .create_large_payload (), headers = headers )
79
83
self .assertEqual (413 , response .status_code )
80
84
0 commit comments