From a33d8f13227dec5a4cb70546497cadddc10a47c6 Mon Sep 17 00:00:00 2001 From: Tommaso Barbugli Date: Fri, 13 Oct 2017 13:34:15 +0200 Subject: [PATCH 1/2] Let requests install SSL libs on old Python Also tidies up travis config. --- .travis.yml | 12 ------------ setup.py | 8 ++++++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0a5f03..38a62a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,21 +7,9 @@ python: - 3.4 - 3.5 - 3.6 - # These are allowed to fail - - '3.5-dev' # 3.5 development branch - - '3.6-dev' # 3.6 development branch - - 'nightly' # currently points to 3.7-dev - - 'pypy' - - 'pypy3.3-5.2-alpha1' matrix: fast_finish: true - allow_failures: - - python: '3.5-dev' # 3.5 development branch - - python: '3.6-dev' # 3.6 development branch - - python: 'nightly' - - python: 'pypy' - - python: 'pypy3.3-5.2-alpha1' cache: pip notifications: diff --git a/setup.py b/setup.py index 2a7e999..b13eabc 100644 --- a/setup.py +++ b/setup.py @@ -26,14 +26,18 @@ .. _`Github`: https://github.com/GetStream/stream-python ''' +requests = 'requests>=2.3.0,<3' + +if sys.version_info < (2, 7, 9): + requests = 'requests[security]>=2.4.1,<3' + install_requires = [ 'pyjwt==1.3.0', - 'requests>=2.2.1', + requests, 'six>=1.8.0', 'httpsig==1.1.2' ] - class PyTest(TestCommand): def finalize_options(self): From 55deb5b67c34c661ddff01af1ea8bc3cf141bd71 Mon Sep 17 00:00:00 2001 From: Dwight Gunning Date: Thu, 12 Oct 2017 18:13:15 +0200 Subject: [PATCH 2/2] Updated domain to stream-io-api.com Updated tests and added extra heroku compatibility tests --- stream/__init__.py | 2 +- stream/client.py | 6 +++--- stream/tests.py | 28 ++++++++++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/stream/__init__.py b/stream/__init__.py index 4fce3d3..8ab4f64 100644 --- a/stream/__init__.py +++ b/stream/__init__.py @@ -29,7 +29,7 @@ def connect(api_key=None, api_secret=None, app_id=None, version='v1.0', result = pattern.match(stream_url) if result and len(result.groups()) == 4: api_key, api_secret, location, app_id = result.groups() - location = None if location == 'getstream' else location + location = None if location in ('getstream', 'stream-io-api') else location else: raise ValueError('Invalid api key or heroku url') diff --git a/stream/client.py b/stream/client.py index f97b110..2bbdc87 100644 --- a/stream/client.py +++ b/stream/client.py @@ -17,7 +17,7 @@ class StreamClient(object): - base_url = 'https://api.getstream.io/api/' + base_url = 'https://api.stream-io-api.com/api/' def __init__(self, api_key, api_secret, app_id, version='v1.0', timeout=6.0, base_url=None, location=None): ''' @@ -57,9 +57,9 @@ def __init__(self, api_key, api_secret, app_id, version='v1.0', timeout=6.0, bas elif base_url is not None: self.base_url = base_url elif location is not None: - self.base_url = 'https://%s-api.getstream.io/api/' % location + self.base_url = 'https://%s-api.stream-io-api.com/api/' % location - self.base_analytics_url = 'https://analytics.getstream.io/analytics/' + self.base_analytics_url = 'https://analytics.stream-io-api.com/analytics/' self.session = requests.Session() # TODO: turn this back on after we verify it doesnt retry on slower requests diff --git a/stream/tests.py b/stream/tests.py index 0b145a3..2c2eb2e 100644 --- a/stream/tests.py +++ b/stream/tests.py @@ -44,7 +44,7 @@ def connect_debug(): secret, location='us-east', timeout=30, - base_url='http://qa-api.getstream.io/api/', + base_url='https://qa.stream-io-api.com/api/', # base_url='http://localhost-api.getstream.io:8000/api/', ) @@ -174,7 +174,7 @@ def test_heroku(self): self.assertEqual(client.app_id, '1') def test_heroku_no_location(self): - url = 'https://bvt88g4kvc63:twc5ywfste5bm2ngqkzs7ukxk3pn96yweghjrxcmcrarnt3j4dqj3tucbhym5wfd@getstream.io/?app_id=669' + url = 'https://bvt88g4kvc63:twc5ywfste5bm2ngqkzs7ukxk3pn96yweghjrxcmcrarnt3j4dqj3tucbhym5wfd@stream-io-api.com/?app_id=669' os.environ['STREAM_URL'] = url client = stream.connect() self.assertEqual(client.api_key, 'bvt88g4kvc63') @@ -187,9 +187,9 @@ def test_heroku_no_location(self): client.base_url, 'http://localhost:8000/api/') else: self.assertEqual( - client.base_url, 'https://api.getstream.io/api/') + client.base_url, 'https://api.stream-io-api.com/api/') - def test_heroku_location(self): + def test_heroku_location_compat(self): url = 'https://ahj2ndz7gsan:gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy@us-east.getstream.io/?app_id=1' os.environ['STREAM_URL'] = url client = stream.connect() @@ -202,7 +202,23 @@ def test_heroku_location(self): client.base_url, 'http://localhost:8000/api/') else: self.assertEqual( - client.base_url, 'https://us-east-api.getstream.io/api/') + client.base_url, 'https://us-east-api.stream-io-api.com/api/') + self.assertEqual(client.app_id, '1') + + def test_heroku_location(self): + url = 'https://ahj2ndz7gsan:gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy@us-east.stream-io-api.com/?app_id=1' + os.environ['STREAM_URL'] = url + client = stream.connect() + self.assertEqual(client.api_key, 'ahj2ndz7gsan') + self.assertEqual( + client.api_secret, 'gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy') + + if self.local_tests: + self.assertEqual( + client.base_url, 'http://localhost:8000/api/') + else: + self.assertEqual( + client.base_url, 'https://us-east-api.stream-io-api.com/api/') self.assertEqual(client.app_id, '1') def test_heroku_overwrite(self): @@ -216,7 +232,7 @@ def test_heroku_overwrite(self): def test_location_support(self): client = stream.connect('a', 'b', 'c', location='us-east') - full_location = 'https://us-east-api.getstream.io/api/' + full_location = 'https://us-east-api.stream-io-api.com/api/' if self.local_tests: full_location = 'http://localhost:8000/api/'