From 223846d3faa72b0537014b384a3dc9d820fa1d4c Mon Sep 17 00:00:00 2001 From: Siddharth Date: Fri, 14 Jan 2022 14:34:52 +0530 Subject: [PATCH 1/3] Issue #132 Fixed --- stream/feed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stream/feed.py b/stream/feed.py index 5a17340..bf76c22 100644 --- a/stream/feed.py +++ b/stream/feed.py @@ -20,7 +20,7 @@ def __init__(self, client, feed_slug, user_id, token): self.slug = feed_slug self.user_id = str(user_id) self.id = "%s:%s" % (feed_slug, user_id) - self.token = token + self.token = token.decode('utf-8') self.feed_url = "feed/%s/" % self.id.replace(":", "/") self.enriched_feed_url = "enrich/feed/%s/" % self.id.replace(":", "/") From 616c04f47d31ba5c1c75fb2c1b221ab7b9d9bdd9 Mon Sep 17 00:00:00 2001 From: Siddharth Date: Fri, 14 Jan 2022 17:18:41 +0530 Subject: [PATCH 2/3] Backword compatibility support added for token --- stream/feed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stream/feed.py b/stream/feed.py index bf76c22..32040e7 100644 --- a/stream/feed.py +++ b/stream/feed.py @@ -20,7 +20,7 @@ def __init__(self, client, feed_slug, user_id, token): self.slug = feed_slug self.user_id = str(user_id) self.id = "%s:%s" % (feed_slug, user_id) - self.token = token.decode('utf-8') + self.token = token.decode('utf-8') if isinstance(token, bytes) else token self.feed_url = "feed/%s/" % self.id.replace(":", "/") self.enriched_feed_url = "enrich/feed/%s/" % self.id.replace(":", "/") From 87c1c816d6ebfd165a0604306c9c0e98f7f0b8a8 Mon Sep 17 00:00:00 2001 From: Siddharth Date: Sat, 15 Jan 2022 17:54:42 +0530 Subject: [PATCH 3/3] Test case added for Feed constructor --- stream/tests/test_client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stream/tests/test_client.py b/stream/tests/test_client.py index ae69175..bf0db9b 100644 --- a/stream/tests/test_client.py +++ b/stream/tests/test_client.py @@ -17,6 +17,7 @@ import stream from stream import serializer from stream.exceptions import ApiKeyException, InputException +from stream.feed import Feed try: from unittest.case import TestCase @@ -1702,3 +1703,13 @@ def test_follow_stats(self): )["results"] self.assertEqual(response["following"]["count"], 0) self.assertEqual(response["followers"]["count"], 1) + + def test_token_type(self): + """ + test to check whether token is a byte or string + """ + with_bytes = Feed(client, "user", "1", b"token") + self.assertEqual(with_bytes.token, "token") + + with_str = Feed(client, "user", "1", "token") + self.assertEqual(with_str.token, "token")