From a5fc8275136d995cb5c6a9062609ec9fc99b694c Mon Sep 17 00:00:00 2001 From: Xin Yang Date: Tue, 1 Jun 2021 21:53:47 +0800 Subject: [PATCH] ignore datacontenttype when using to_binary() (#138) * ignore datacontenttype when using to_binary() Signed-off-by: XinYang * fix tests Signed-off-by: XinYang * fix tests. sanic>20.12 does not support py3.6 any more Signed-off-by: XinYang --- cloudevents/sdk/event/base.py | 2 +- cloudevents/tests/test_with_sanic.py | 2 +- requirements/test.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cloudevents/sdk/event/base.py b/cloudevents/sdk/event/base.py index 7dc5d72..c092946 100644 --- a/cloudevents/sdk/event/base.py +++ b/cloudevents/sdk/event/base.py @@ -292,7 +292,7 @@ class BaseEvent(EventGetterSetter): headers["content-type"] = self.ContentType() props = self.Properties() for key, value in props.items(): - if key not in ["data", "extensions", "contenttype"]: + if key not in ["data", "extensions", "datacontenttype"]: if value is not None: headers["ce-{0}".format(key)] = value diff --git a/cloudevents/tests/test_with_sanic.py b/cloudevents/tests/test_with_sanic.py index 135bfd5..e02f650 100644 --- a/cloudevents/tests/test_with_sanic.py +++ b/cloudevents/tests/test_with_sanic.py @@ -34,7 +34,7 @@ async def echo(request): v1.Event(), dict(request.headers), request.body, lambda x: x ) hs, body = m.ToRequest(event, converters.TypeBinary, lambda x: x) - return response.text(body, headers=hs) + return response.text(body.decode("utf-8"), headers=hs) def test_reusable_marshaller(): diff --git a/requirements/test.txt b/requirements/test.txt index 6aa95bd..d4cf81e 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -6,7 +6,7 @@ flake8-strict pytest==4.0.0 pytest-cov==2.4.0 # web app tests -sanic +sanic==20.12.3 aiohttp Pillow requests