Skip to content

Commit 5e4289c

Browse files
committed
local support
1 parent e90ec60 commit 5e4289c

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎README.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,7 @@ First, make sure you can run the test suite. Tests are run via py.test
6767
py.test stream/tests.py
6868
# with coverage
6969
py.test stream/tests.py --cov stream --cov-report html
70+
# against a local API backend
71+
LOCAL=true py.test stream/tests.py
7072

7173

‎stream/client.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import logging
44
from stream.signing import sign
55
from stream.utils import validate_feed
6+
import os
67

78
logger = logging.getLogger(__name__)
89

910

1011
class StreamClient(object):
1112
base_url = 'https://getstream.io/api/'
12-
# base_url = 'http://localhost:8000/api/'
1313

1414
def __init__(self, api_key, api_secret, base_url=None):
1515
'''
@@ -40,6 +40,8 @@ def __init__(self, api_key, api_secret, base_url=None):
4040
self.api_secret = api_secret
4141
if base_url is not None:
4242
self.base_url = base_url
43+
if os.environ.get('LOCAL'):
44+
self.base_url = 'http://localhost:8000/api/'
4345

4446
def feed(self, feed_id):
4547
'''
@@ -77,10 +79,10 @@ def _make_request(self, method, relative_url, feed, params=None, data=None):
7779
headers = self.get_headers(feed)
7880
url = self.base_url + relative_url
7981

80-
logger.debug('stream api call %s, headers %s params %s data %s',
81-
url, headers, default_params, data)
8282
response = method(url, data=data, headers=headers,
8383
params=default_params)
84+
logger.debug('stream api call %s, headers %s data %s',
85+
response.url, headers, data)
8486
result = response.json()
8587
if result.get('exception'):
8688
self.raise_exception(result, status_code=response.status_code)

‎stream/tests.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_follow(self):
3434
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1}
3535
activity_id = self.user1.add_activity(activity_data)['id']
3636
self.aggregated2.follow('user:1')
37-
time.sleep(5)
37+
time.sleep(10)
3838
activities = self.aggregated2.get(limit=3)['results']
3939
activity = self._get_first_aggregated_activity(activities)
4040
activity_id_found = activity['id'] if activity is not None else None

0 commit comments

Comments
 (0)