Skip to content

Commit 68a24ae

Browse files
authored
Merge branch 'master' into sni
2 parents 2326bb3 + aac832d commit 68a24ae

5 files changed

Lines changed: 59 additions & 48 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ docs/_build/
5454

5555
secrets.*sh
5656
.idea
57+
58+
.venv

‎.travis.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ python:
1111
- '3.6-dev' # 3.6 development branch
1212
- 'nightly' # currently points to 3.7-dev
1313
- 'pypy-5.3.1'
14-
- 'pypy3'
14+
- 'pypy3.3-5.2-alpha1'
1515

1616
matrix:
1717
fast_finish: true
@@ -20,7 +20,7 @@ matrix:
2020
- python: '3.6-dev' # 3.6 development branch
2121
- python: 'nightly'
2222
- python: 'pypy-5.3.1'
23-
- python: 'pypy3'
23+
- python: 'pypy3.3-5.2-alpha1'
2424

2525
cache: pip
2626
notifications:

‎LICENSE‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
Copyright (c) 2014, Stream.io, Inc
1+
Copyright (c) 2014-2017 Stream.io Inc, and individual contributors.
2+
23
All rights reserved.
34

4-
Redistribution and use in source and binary forms, with or without
5-
modification, are permitted provided that the following conditions are met:
5+
Redistribution and use in source and binary forms, with or without modification, are permitted
6+
provided that the following conditions are met:
67

7-
* Redistributions of source code must retain the above copyright notice, this
8-
list of conditions and the following disclaimer.
8+
1. Redistributions of source code must retain the above copyright notice, this list of
9+
conditions and the following disclaimer.
910

10-
* Redistributions in binary form must reproduce the above copyright notice,
11-
this list of conditions and the following disclaimer in the documentation
12-
and/or other materials provided with the distribution.
11+
2. Redistributions in binary form must reproduce the above copyright notice, this list of
12+
conditions and the following disclaimer in the documentation and/or other materials
13+
provided with the distribution.
1314

14-
* Neither the name of the {organization} nor the names of its
15-
contributors may be used to endorse or promote products derived from
16-
this software without specific prior written permission.
15+
3. Neither the name of the copyright holder nor the names of its contributors may
16+
be used to endorse or promote products derived from this software without specific prior
17+
written permission.
1718

18-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
POSSIBILITY OF SUCH DAMAGE.

‎README.md‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ stream-python
33

44
[![Build Status](https://travis-ci.org/GetStream/stream-python.svg?branch=master)](https://travis-ci.org/GetStream/stream-python) [![Coverage Status](https://coveralls.io/repos/github/GetStream/stream-python/badge.svg?branch=master)](https://coveralls.io/r/GetStream/stream-python?branch=master) [![PyPI version](https://badge.fury.io/py/stream-python.svg)](http://badge.fury.io/py/stream-python)
55

6-
stream-python is the official Python client for [Stream](https://getstream.io/), a web service for building scalable newsfeeds and activity streams.
7-
The full documentation is available on [GetStream.io/docs](http://getstream.io/docs/?language=python). Note that there is also a [higher level Django integration](https://github.com/getstream/stream-django) which hooks into your ORM.
6+
[stream-python](https://github.com/GetStream/stream-python) is the official Python client for [Stream](https://getstream.io/), a web service for building scalable newsfeeds and activity streams.
7+
8+
Note there is also a higher level [Django - Stream integration](https://github.com/getstream/stream-django) library which hooks into the Django ORM.
9+
10+
You can sign up for a Stream account at https://getstream.io/get_started.
811

912
### Installation
1013

1114
#### Install from Pypi
1215

13-
1416
```bash
1517
pip install stream-python
1618
```
1719

20+
### Full documentation
21+
22+
Documentation for this Python client are available at the [Stream website](https://getstream.io/docs/?language=python) or on [Read the Docs](http://stream-python.readthedocs.org/en/latest/).
23+
1824
### Usage
1925

2026
```python
@@ -38,7 +44,7 @@ result = user_feed_1.get(limit=5, id_lt="e561de8f-00f1-11e4-b400-0cc47a024be0")
3844
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'foreign_id': 'tweet:1'}
3945
activity_response = user_feed_1.add_activity(activity_data)
4046
# Create a bit more complex activity
41-
activity_data = {'actor': 1, 'verb': 'run', 'object': 1, 'foreign_id': 'run:1',
47+
activity_data = {'actor': 1, 'verb': 'run', 'object': 1, 'foreign_id': 'run:1',
4248
'course': {'name': 'Golden Gate park', 'distance': 10},
4349
'participants': ['Thierry', 'Tommaso'],
4450
'started_at': datetime.datetime.now()
@@ -97,19 +103,19 @@ readonly_token = user_feed_1.get_readonly_token()
97103
# Generate a redirect url for the Stream Analytics platform to track
98104
# events/impressions on url clicks
99105
impression = {
100-
'content_list': ['tweet:1', 'tweet:2', 'tweet:3'],
101-
'user_data': 'tommaso',
106+
'content_list': ['tweet:1', 'tweet:2', 'tweet:3'],
107+
'user_data': 'tommaso',
102108
'location': 'email',
103109
'feed_id': 'user:global'
104110
}
105111

106112
engagement = {
107-
'content': 'tweet:2',
113+
'content': 'tweet:2',
108114
'label': 'click',
109-
'position': 1,
110-
'user_data': 'tommaso',
115+
'position': 1,
116+
'user_data': 'tommaso',
111117
'location': 'email',
112-
'feed_id':
118+
'feed_id':
113119
'user:global'
114120
}
115121

@@ -118,12 +124,6 @@ events = [impression, engagement]
118124
redirect_url = client.create_redirect_url('http://google.com/', 'user_id', events)
119125
```
120126

121-
122-
123-
API docs are on [Read the
124-
docs](http://stream-python.readthedocs.org/en/latest/).
125-
126-
127127
[JS client](http://github.com/getstream/stream-js).
128128

129129
### Contributing
@@ -137,3 +137,9 @@ py.test stream/tests.py --cov stream --cov-report html
137137
# against a local API backend
138138
LOCAL=true py.test stream/tests.py
139139
```
140+
141+
### Copyright and License Information
142+
143+
Copyright (c) 2014-2017 Stream.io Inc, and individual contributors. All rights reserved.
144+
145+
See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.

‎stream/tests.py‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,21 @@ def getfeed(feed_slug, user_id):
6161
return client.feed(feed_slug, user_id + get_unique_postfix())
6262

6363

64+
def api_request_parse_validator(test):
65+
def wrapper(meth):
66+
def _parse_response(*args, **kwargs):
67+
response = meth(*args, **kwargs)
68+
test.assertIn('duration', response)
69+
return response
70+
return _parse_response
71+
return wrapper
72+
73+
6474
class ClientTest(TestCase):
6575

6676
def setUp(self):
77+
client._parse_response = api_request_parse_validator(self)(client._parse_response)
78+
6779
# DEBUG account details
6880
user1 = getfeed('user', '1')
6981
user2 = getfeed('user', '2')
@@ -416,11 +428,8 @@ def test_follow_and_delete(self):
416428
actor_id = random.randint(10, 100000)
417429
activity_data = {'actor': actor_id, 'verb': 'tweet', 'object': 1}
418430
activity_id = user_feed.add_activity(activity_data)['id']
419-
420-
421431
agg_feed.follow(user_feed.slug, user_feed.user_id)
422432
user_feed.remove_activity(activity_id)
423-
424433
activities = agg_feed.get(limit=3)['results']
425434
activity = self._get_first_aggregated_activity(activities)
426435
activity_id_found = (activity['id'] if activity is not None
@@ -813,12 +822,6 @@ def test_serialization(self):
813822
loaded = serializer.loads(serialized)
814823
self.assertEqual(data, loaded)
815824

816-
def test_signed_request_post(self):
817-
self.c._make_signed_request('post', 'test/auth/digest/', {}, {})
818-
819-
def test_signed_request_get(self):
820-
self.c._make_signed_request('post', 'test/auth/digest/', {}, {})
821-
822825
def test_follow_many(self):
823826
sources = [getfeed('user', str(i)).id for i in range(10)]
824827
targets = [getfeed('flat', str(i)).id for i in range(10)]

0 commit comments

Comments
 (0)