@@ -48,7 +48,7 @@ def test_executor_with_json_body_and_number_variable():
48
48
assert executor .method == "post"
49
49
assert executor .url == "https://api.example.com/data"
50
50
assert executor .headers == {"Content-Type" : "application/json" }
51
- assert executor .params == {}
51
+ assert executor .params == []
52
52
assert executor .json == {"number" : 42 }
53
53
assert executor .data is None
54
54
assert executor .files is None
@@ -101,7 +101,7 @@ def test_executor_with_json_body_and_object_variable():
101
101
assert executor .method == "post"
102
102
assert executor .url == "https://api.example.com/data"
103
103
assert executor .headers == {"Content-Type" : "application/json" }
104
- assert executor .params == {}
104
+ assert executor .params == []
105
105
assert executor .
json == {
"name" :
"John Doe" ,
"age" :
30 ,
"email" :
"[email protected] " }
106
106
assert executor .data is None
107
107
assert executor .files is None
@@ -156,7 +156,7 @@ def test_executor_with_json_body_and_nested_object_variable():
156
156
assert executor .method == "post"
157
157
assert executor .url == "https://api.example.com/data"
158
158
assert executor .headers == {"Content-Type" : "application/json" }
159
- assert executor .params == {}
159
+ assert executor .params == []
160
160
assert executor .
json == {
"object" : {
"name" :
"John Doe" ,
"age" :
30 ,
"email" :
"[email protected] " }}
161
161
assert executor .data is None
162
162
assert executor .files is None
@@ -195,7 +195,7 @@ def test_extract_selectors_from_template_with_newline():
195
195
variable_pool = variable_pool ,
196
196
)
197
197
198
- assert executor .params == { "test" : "line1\n line2" }
198
+ assert executor .params == [( "test" , "line1\n line2" )]
199
199
200
200
201
201
def test_executor_with_form_data ():
@@ -244,7 +244,7 @@ def test_executor_with_form_data():
244
244
assert executor .url == "https://api.example.com/upload"
245
245
assert "Content-Type" in executor .headers
246
246
assert "multipart/form-data" in executor .headers ["Content-Type" ]
247
- assert executor .params == {}
247
+ assert executor .params == []
248
248
assert executor .json is None
249
249
assert executor .files is None
250
250
assert executor .content is None
@@ -265,3 +265,72 @@ def test_executor_with_form_data():
265
265
assert "Hello, World!" in raw_request
266
266
assert "number_field" in raw_request
267
267
assert "42" in raw_request
268
+
269
+
270
+ def test_init_headers ():
271
+ def create_executor (headers : str ) -> Executor :
272
+ node_data = HttpRequestNodeData (
273
+ title = "test" ,
274
+ method = "get" ,
275
+ url = "http://example.com" ,
276
+ headers = headers ,
277
+ params = "" ,
278
+ authorization = HttpRequestNodeAuthorization (type = "no-auth" ),
279
+ )
280
+ timeout = HttpRequestNodeTimeout (connect = 10 , read = 30 , write = 30 )
281
+ return Executor (node_data = node_data , timeout = timeout , variable_pool = VariablePool ())
282
+
283
+ executor = create_executor ("aa\n cc:" )
284
+ executor ._init_headers ()
285
+ assert executor .headers == {"aa" : "" , "cc" : "" }
286
+
287
+ executor = create_executor ("aa:bb\n cc:dd" )
288
+ executor ._init_headers ()
289
+ assert executor .headers == {"aa" : "bb" , "cc" : "dd" }
290
+
291
+ executor = create_executor ("aa:bb\n cc:dd\n " )
292
+ executor ._init_headers ()
293
+ assert executor .headers == {"aa" : "bb" , "cc" : "dd" }
294
+
295
+ executor = create_executor ("aa:bb\n \n cc : dd\n \n " )
296
+ executor ._init_headers ()
297
+ assert executor .headers == {"aa" : "bb" , "cc" : "dd" }
298
+
299
+
300
+ def test_init_params ():
301
+ def create_executor (params : str ) -> Executor :
302
+ node_data = HttpRequestNodeData (
303
+ title = "test" ,
304
+ method = "get" ,
305
+ url = "http://example.com" ,
306
+ headers = "" ,
307
+ params = params ,
308
+ authorization = HttpRequestNodeAuthorization (type = "no-auth" ),
309
+ )
310
+ timeout = HttpRequestNodeTimeout (connect = 10 , read = 30 , write = 30 )
311
+ return Executor (node_data = node_data , timeout = timeout , variable_pool = VariablePool ())
312
+
313
+ # Test basic key-value pairs
314
+ executor = create_executor ("key1:value1\n key2:value2" )
315
+ executor ._init_params ()
316
+ assert executor .params == [("key1" , "value1" ), ("key2" , "value2" )]
317
+
318
+ # Test empty values
319
+ executor = create_executor ("key1:\n key2:" )
320
+ executor ._init_params ()
321
+ assert executor .params == [("key1" , "" ), ("key2" , "" )]
322
+
323
+ # Test duplicate keys (which is allowed for params)
324
+ executor = create_executor ("key1:value1\n key1:value2" )
325
+ executor ._init_params ()
326
+ assert executor .params == [("key1" , "value1" ), ("key1" , "value2" )]
327
+
328
+ # Test whitespace handling
329
+ executor = create_executor (" key1 : value1 \n key2 : value2 " )
330
+ executor ._init_params ()
331
+ assert executor .params == [("key1" , "value1" ), ("key2" , "value2" )]
332
+
333
+ # Test empty lines and extra whitespace
334
+ executor = create_executor ("key1:value1\n \n key2:value2\n \n " )
335
+ executor ._init_params ()
336
+ assert executor .params == [("key1" , "value1" ), ("key2" , "value2" )]
0 commit comments