@@ -78,7 +78,7 @@ async def echo(request):
78
78
if "binary-payload" in request .headers :
79
79
decoder = lambda x : x
80
80
event = from_http (
81
- request . body , headers = dict (request .headers ), data_unmarshaller = decoder
81
+ dict (request .headers ), request . body , data_unmarshaller = decoder
82
82
)
83
83
data = (
84
84
event .data
@@ -96,8 +96,7 @@ def test_missing_required_fields_structured(body):
96
96
# implemented. In this instance one of the required keys should have
97
97
# prefix e-id instead of ce-id therefore it should throw
98
98
_ = from_http (
99
- json .dumps (body ),
100
- headers = {"Content-Type" : "application/cloudevents+json" },
99
+ {"Content-Type" : "application/cloudevents+json" }, json .dumps (body ),
101
100
)
102
101
103
102
@@ -108,7 +107,7 @@ def test_missing_required_fields_binary(headers):
108
107
# and NotImplementedError because structured calls aren't
109
108
# implemented. In this instance one of the required keys should have
110
109
# prefix e-id instead of ce-id therefore it should throw
111
- _ = from_http (json .dumps (test_data ), headers = headers )
110
+ _ = from_http (headers , json .dumps (test_data ))
112
111
113
112
114
113
@pytest .mark .parametrize ("specversion" , ["1.0" , "0.3" ])
@@ -208,7 +207,7 @@ def test_missing_ce_prefix_binary_event(specversion):
208
207
# and NotImplementedError because structured calls aren't
209
208
# implemented. In this instance one of the required keys should have
210
209
# prefix e-id instead of ce-id therefore it should throw
211
- _ = from_http (json .dumps (test_data ), headers = prefixed_headers )
210
+ _ = from_http (prefixed_headers , json .dumps (test_data ))
212
211
213
212
214
213
@pytest .mark .parametrize ("specversion" , ["1.0" , "0.3" ])
@@ -225,7 +224,7 @@ def test_valid_binary_events(specversion):
225
224
"ce-specversion" : specversion ,
226
225
}
227
226
data = {"payload" : f"payload-{ i } " }
228
- events_queue .append (from_http (json .dumps (data ), headers = headers ))
227
+ events_queue .append (from_http (headers , json .dumps (data )))
229
228
230
229
for i , event in enumerate (events_queue ):
231
230
data = event .data
@@ -288,7 +287,7 @@ def test_empty_data_structured_event(specversion):
288
287
}
289
288
290
289
_ = from_http (
291
- json . dumps ( attributes ), {"content-type" : "application/cloudevents+json" }
290
+ {"content-type" : "application/cloudevents+json" }, json . dumps ( attributes )
292
291
)
293
292
294
293
@@ -303,7 +302,7 @@ def test_empty_data_binary_event(specversion):
303
302
"ce-time" : "2018-10-23T12:28:22.4579346Z" ,
304
303
"ce-source" : "<source-url>" ,
305
304
}
306
- _ = from_http ("" , headers )
305
+ _ = from_http (headers , "" )
307
306
308
307
309
308
@pytest .mark .parametrize ("specversion" , ["1.0" , "0.3" ])
@@ -321,8 +320,8 @@ def test_valid_structured_events(specversion):
321
320
}
322
321
events_queue .append (
323
322
from_http (
324
- json .dumps (event ),
325
323
{"content-type" : "application/cloudevents+json" },
324
+ json .dumps (event ),
326
325
)
327
326
)
328
327
@@ -343,7 +342,7 @@ def test_structured_no_content_type(specversion):
343
342
"specversion" : specversion ,
344
343
"data" : test_data ,
345
344
}
346
- event = from_http (json .dumps (data ), {}, )
345
+ event = from_http ({}, json .dumps (data ))
347
346
348
347
assert event ["id" ] == "id"
349
348
assert event ["source" ] == "source.com.test"
@@ -381,7 +380,7 @@ def test_cloudevent_repr(specversion):
381
380
"ce-time" : "2018-10-23T12:28:22.4579346Z" ,
382
381
"ce-source" : "<source-url>" ,
383
382
}
384
- event = from_http ("" , headers )
383
+ event = from_http (headers , "" )
385
384
# Testing to make sure event is printable. I could runevent. __repr__() but
386
385
# we had issues in the past where event.__repr__() could run but
387
386
# print(event) would fail.
@@ -412,15 +411,15 @@ def test_wrong_specversion():
412
411
}
413
412
)
414
413
with pytest .raises (cloud_exceptions .CloudEventTypeErrorRequiredFields ) as e :
415
- from_http (data , headers )
414
+ from_http (headers , data )
416
415
assert "Found invalid specversion 0.2" in str (e .value )
417
416
418
417
419
418
def test_invalid_data_format_structured_from_http ():
420
419
headers = {"Content-Type" : "application/cloudevents+json" }
421
420
data = 20
422
421
with pytest .raises (cloud_exceptions .InvalidStructuredJSON ) as e :
423
- from_http (data , headers )
422
+ from_http (headers , data )
424
423
assert "Expected json of type (str, bytes, bytearray)" in str (e .value )
425
424
426
425
@@ -452,7 +451,9 @@ def test_empty_json_structured():
452
451
headers = {"Content-Type" : "application/cloudevents+json" }
453
452
data = ""
454
453
with pytest .raises (cloud_exceptions .InvalidStructuredJSON ) as e :
455
- from_http (data , headers )
454
+ from_http (
455
+ headers , data ,
456
+ )
456
457
assert "Failed to read fields from structured event. " in str (e .value )
457
458
458
459
@@ -463,7 +464,7 @@ def test_uppercase_headers_with_none_data_binary():
463
464
"Ce-Type" : "cloudevent.event.type" ,
464
465
"Ce-Specversion" : "1.0" ,
465
466
}
466
- event = from_http (None , headers )
467
+ event = from_http (headers , None )
467
468
468
469
for key in headers :
469
470
assert event [key .lower ()[3 :]] == headers [key ]
0 commit comments