Skip to content

Commit 8633a0b

Browse files
committed
CI improvements
1 parent 3a1e7f7 commit 8633a0b

File tree

8 files changed

+76
-59
lines changed

8 files changed

+76
-59
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
language: python
2-
dist: xenial
32
matrix:
43
include:
54
- python: 3.5
65
- python: 3.6
76
- python: 3.7
87
- python: 3.8
9-
sudo: true
108
cache: pip
119
install:
1210
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then pip install black; fi
@@ -16,7 +14,7 @@ install:
1614
script:
1715
- echo $STREAM_KEY
1816
- python setup.py test
19-
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then black stream_chat; fi
17+
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then black --check stream_chat; fi
2018
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then pycodestyle --ignore=E501,E225,W293 stream_chat; fi
2119
- python setup.py install
2220
after_script:

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# stream-chat-python
1+
# stream-chat-python
22

33
[![Build Status](https://travis-ci.com/GetStream/stream-chat-python.svg?token=WystDPP9vxKnwsd8NwW1&branch=master)](https://travis-ci.com/GetStream/stream-chat-python) [![codecov](https://codecov.io/gh/GetStream/stream-chat-python/branch/master/graph/badge.svg?token=DM7rr9M7Kl)](https://codecov.io/gh/GetStream/stream-chat-python) [![PyPI version](https://badge.fury.io/py/stream-chat.svg)](http://badge.fury.io/py/stream-chat) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/stream-chat.svg)
44

@@ -16,21 +16,21 @@ pip install stream-chat
1616

1717
### Documentation
1818

19-
[Official API docs](https://getstream.io/chat/docs/)
19+
[Official API docs](https://getstream.io/chat/docs/)
2020

2121
### How to build a chat app with Python tutorial
2222

2323
[Chat with Python, Django and React](https://github.com/GetStream/python-chat-example)
2424

2525
### Supported features
2626

27-
- Chat channels
27+
- Chat channels
2828
- Messages
29-
- Chat channel types
30-
- User management
31-
- Moderation API
32-
- Push configuration
33-
- User devices
29+
- Chat channel types
30+
- User management
31+
- Moderation API
32+
- Push configuration
33+
- User devices
3434
- User search
3535
- Channel search
3636

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.black]
22
line-length = 88
3-
py36 = true
3+
target-version = ["py36"]
44
include = '\.pyi?$'
55
exclude = '''
66
/(
@@ -21,4 +21,4 @@ exclude = '''
2121
| build
2222
| dist
2323
)/
24-
'''
24+
'''

stream_chat/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from .client import StreamChat
2-

stream_chat/channel.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ def get_reactions(self, message_id, **options):
196196
:param options: Pagination params, ie {"limit":10, "idlte": 10}
197197
:return: A response with a list of reactions
198198
"""
199-
return self.client.get("messages/{}/reactions".format(message_id), params=options)
199+
return self.client.get(
200+
"messages/{}/reactions".format(message_id), params=options
201+
)
200202

201203
def ban_user(self, target_id, **options):
202204
"""
@@ -223,23 +225,27 @@ def unban_user(self, target_id, **options):
223225

224226
def accept_invite(self, user_id, **data):
225227
payload = add_user_id(data, user_id)
226-
payload['accept_invite'] = True
228+
payload["accept_invite"] = True
227229
response = self.client.post(self.url, data=payload)
228-
self.custom_data = response['channel']
230+
self.custom_data = response["channel"]
229231
return response
230232

231233
def reject_invite(self, user_id, **data):
232234
payload = add_user_id(data, user_id)
233-
payload['reject_invite'] = True
235+
payload["reject_invite"] = True
234236
response = self.client.post(self.url, data=payload)
235-
self.custom_data = response['channel']
237+
self.custom_data = response["channel"]
236238
return response
237239

238240
def send_file(self, url, name, user, content_type=None):
239-
return self.client.send_file("{}/file".format(self.url), url, name, user, content_type=content_type)
241+
return self.client.send_file(
242+
"{}/file".format(self.url), url, name, user, content_type=content_type
243+
)
240244

241245
def send_image(self, url, name, user, content_type=None):
242-
return self.client.send_file("{}/image".format(self.url), url, name, user, content_type=content_type)
246+
return self.client.send_file(
247+
"{}/image".format(self.url), url, name, user, content_type=content_type
248+
)
243249

244250
def delete_file(self, url):
245251
return self.client.delete("{}/file".format(self.url), {"url": url})

stream_chat/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ def __init__(self, response):
1010
try:
1111
parsed_response = response.json()
1212
self.error_code = parsed_response.get("code", "unknown")
13-
self.error_message = parsed_response.get(
14-
"message", "unknown"
15-
)
13+
self.error_message = parsed_response.get("message", "unknown")
1614
self.json_response = True
1715
except ValueError:
1816
pass
1917

2018
def __str__(self):
2119
if self.json_response:
22-
return "StreamChat error code {}: {}".format(self.error_code, self.error_message)
20+
return "StreamChat error code {}: {}".format(
21+
self.error_code, self.error_message
22+
)
2323
else:
2424
return "StreamChat error HTTP code: {}".format(self.response.status_code)

stream_chat/tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def pytest_runtest_setup(item):
1818
if previousfailed is not None:
1919
pytest.xfail("previous test failed (%s)" % previousfailed.name)
2020

21+
2122
def pytest_configure(config):
22-
config.addinivalue_line(
23-
"markers", "incremental: mark test incremental"
24-
)
23+
config.addinivalue_line("markers", "incremental: mark test incremental")
24+
2525

2626
@pytest.fixture(scope="module")
2727
def client():

stream_chat/tests/test_channel.py

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -136,69 +136,83 @@ def test_get_reactions(self, channel, random_user):
136136
def test_send_and_delete_file(self, channel, random_user):
137137
url = "https://homepages.cae.wisc.edu/~ece533/images/lena.png"
138138
resp = channel.send_file(url, "lena.png", random_user)
139-
assert "lena.png" in resp['file']
140-
resp = channel.delete_file(resp['file'])
139+
assert "lena.png" in resp["file"]
140+
resp = channel.delete_file(resp["file"])
141141

142142
def test_send_and_delete_image(self, channel, random_user):
143143
url = "https://homepages.cae.wisc.edu/~ece533/images/lena.png"
144-
resp = channel.send_image(url, "lena.png", random_user, content_type="image/png")
145-
assert "lena.png" in resp['file']
144+
resp = channel.send_image(
145+
url, "lena.png", random_user, content_type="image/png"
146+
)
147+
assert "lena.png" in resp["file"]
146148
# resp = channel.delete_image(resp['file'])
147149

148150
def test_channel_hide_show(self, client, channel, random_users):
149151
# setup
150-
channel.add_members([u['id'] for u in random_users])
152+
channel.add_members([u["id"] for u in random_users])
151153
# verify
152154
response = client.query_channels({"id": channel.id})
153-
assert len(response['channels']) == 1
154-
response = client.query_channels({"id": channel.id}, user_id=random_users[0]['id'])
155-
assert len(response['channels']) == 1
155+
assert len(response["channels"]) == 1
156+
response = client.query_channels(
157+
{"id": channel.id}, user_id=random_users[0]["id"]
158+
)
159+
assert len(response["channels"]) == 1
156160
# hide
157-
channel.hide(random_users[0]['id'])
158-
response = client.query_channels({"id": channel.id}, user_id=random_users[0]['id'])
159-
assert len(response['channels']) == 0
161+
channel.hide(random_users[0]["id"])
162+
response = client.query_channels(
163+
{"id": channel.id}, user_id=random_users[0]["id"]
164+
)
165+
assert len(response["channels"]) == 0
160166
# search hidden channels
161-
response = client.query_channels({"id": channel.id, "hidden": True}, user_id=random_users[0]['id'])
162-
assert len(response['channels']) == 1
167+
response = client.query_channels(
168+
{"id": channel.id, "hidden": True}, user_id=random_users[0]["id"]
169+
)
170+
assert len(response["channels"]) == 1
163171
# unhide
164-
channel.show(random_users[0]['id'])
165-
response = client.query_channels({"id": channel.id}, user_id=random_users[0]['id'])
166-
assert len(response['channels']) == 1
172+
channel.show(random_users[0]["id"])
173+
response = client.query_channels(
174+
{"id": channel.id}, user_id=random_users[0]["id"]
175+
)
176+
assert len(response["channels"]) == 1
167177
# hide again
168-
channel.hide(random_users[0]['id'])
169-
response = client.query_channels({"id": channel.id}, user_id=random_users[0]['id'])
170-
assert len(response['channels']) == 0
178+
channel.hide(random_users[0]["id"])
179+
response = client.query_channels(
180+
{"id": channel.id}, user_id=random_users[0]["id"]
181+
)
182+
assert len(response["channels"]) == 0
171183
# send message
172184
channel.send_message({"text": "hi"}, random_users[1]["id"])
173185
# channel should be listed now
174-
response = client.query_channels({"id": channel.id}, user_id=random_users[0]['id'])
175-
assert len(response['channels']) == 1
186+
response = client.query_channels(
187+
{"id": channel.id}, user_id=random_users[0]["id"]
188+
)
189+
assert len(response["channels"]) == 1
176190

177191
def test_invites(self, client, channel):
178192
members = ["john", "paul", "george", "pete", "ringo", "eric"]
179193
client.update_users([{"id": m} for m in members])
180194
channel = client.channel(
181-
"team", "beatles-" + str(uuid.uuid4()), {
182-
"members": members,
183-
"invites": ["ringo", "eric"]
184-
})
195+
"team",
196+
"beatles-" + str(uuid.uuid4()),
197+
{"members": members, "invites": ["ringo", "eric"]},
198+
)
185199
channel.create("john")
186200
# accept the invite when not a member
187201
with pytest.raises(StreamAPIException):
188202
channel.accept_invite("brian")
189203
# accept the invite when a member
190204
accept = channel.accept_invite("ringo")
191-
for m in accept['members']:
192-
if m['user_id'] == 'ringo':
193-
assert m['invited'] is True
205+
for m in accept["members"]:
206+
if m["user_id"] == "ringo":
207+
assert m["invited"] is True
194208
assert "invite_accepted_at" in m
195209
# cannot accept again
196210
with pytest.raises(StreamAPIException):
197211
channel.accept_invite("ringo")
198212
reject = channel.reject_invite("eric")
199-
for m in reject['members']:
200-
if m['user_id'] == 'eric':
201-
assert m['invited'] is True
213+
for m in reject["members"]:
214+
if m["user_id"] == "eric":
215+
assert m["invited"] is True
202216
assert "invite_rejected_at" in m
203217
# cannot reject again
204218
with pytest.raises(StreamAPIException):

0 commit comments

Comments
 (0)