Skip to content

Commit 76654a9

Browse files
ryandawsonukdi
andauthored
fix small bug with extensions (#25)
* Add a failing test Signed-off-by: Dustin Ingram <[email protected]> * fix small bug with extensions Signed-off-by: ryandawsonuk <[email protected]> Co-authored-by: Dustin Ingram <[email protected]>
1 parent 173ed41 commit 76654a9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

cloudevents/sdk/event/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def MarshalBinary(
154154
if value is not None:
155155
headers["ce-{0}".format(key)] = value
156156

157-
for key, value in props.get("extensions"):
157+
for key, value in props.get("extensions").items():
158158
headers["ce-{0}".format(key)] = value
159159

160160
data, _ = self.Get("data")

cloudevents/tests/test_event_pipeline.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_event_pipeline_upstream():
3737
)
3838
m = marshaller.NewDefaultHTTPMarshaller()
3939
new_headers, body = m.ToRequest(event, converters.TypeBinary, lambda x: x)
40+
4041
assert new_headers is not None
4142
assert "ce-specversion" in new_headers
4243
assert "ce-type" in new_headers
@@ -48,6 +49,20 @@ def test_event_pipeline_upstream():
4849
assert data.body == body
4950

5051

52+
def test_extensions_are_set_upstream():
53+
extensions = {'extension-key': 'extension-value'}
54+
event = (
55+
v02.Event()
56+
.SetExtensions(extensions)
57+
)
58+
59+
m = marshaller.NewDefaultHTTPMarshaller()
60+
new_headers, body = m.ToRequest(event, converters.TypeBinary, lambda x: x)
61+
62+
assert event.Extensions() == extensions
63+
assert "ce-extension-key" in new_headers
64+
65+
5166
def test_event_pipeline_v01():
5267
event = (
5368
v01.Event()

0 commit comments

Comments
 (0)