1+ import uuid
2+
13import pytest
24
5+ from stream_chat .exceptions import StreamAPIException
6+
37
48@pytest .mark .incremental
59class TestChannel (object ):
@@ -122,15 +126,15 @@ def test_get_reactions(self, channel, random_user):
122126 assert response ["reactions" ][0 ]["count" ] == 42
123127
124128 def test_send_and_delete_file (self , channel , random_user ):
125- url = "https://getstream.io/blog/wp-content/themes/stream-theme-wordpress_2018-05-24_10-41/assets/ images/stream_logo .png" ;
126- resp = channel .send_file (url , "logo .png" , random_user )
127- assert "logo .png" in resp ['file' ]
129+ url = "https://homepages.cae.wisc.edu/~ece533/ images/lena .png"
130+ resp = channel .send_file (url , "lena .png" , random_user )
131+ assert "lena .png" in resp ['file' ]
128132 resp = channel .delete_file (resp ['file' ])
129133
130134 def test_send_and_delete_image (self , channel , random_user ):
131- url = "https://getstream.io/blog/wp-content/themes/stream-theme-wordpress_2018-05-24_10-41/assets/ images/stream_logo .png" ;
132- resp = channel .send_image (url , "logo .png" , random_user , content_type = "image/png" )
133- assert "logo .png" in resp ['file' ]
135+ url = "https://homepages.cae.wisc.edu/~ece533/ images/lena .png"
136+ resp = channel .send_image (url , "lena .png" , random_user , content_type = "image/png" )
137+ assert "lena .png" in resp ['file' ]
134138 # resp = channel.delete_image(resp['file'])
135139
136140 def test_channel_hide_show (self , client , channel , random_users ):
@@ -157,7 +161,37 @@ def test_channel_hide_show(self, client, channel, random_users):
157161 response = client .query_channels ({"id" : channel .id }, user_id = random_users [0 ]['id' ])
158162 assert len (response ['channels' ]) == 0
159163 # send message
160- msg = channel .send_message ({"text" : "hi" }, random_users [1 ]["id" ])
164+ channel .send_message ({"text" : "hi" }, random_users [1 ]["id" ])
161165 # channel should be listed now
162166 response = client .query_channels ({"id" : channel .id }, user_id = random_users [0 ]['id' ])
163167 assert len (response ['channels' ]) == 1
168+
169+ def test_invites (self , client , channel ):
170+ members = ["john" , "paul" , "george" , "pete" , "ringo" , "eric" ]
171+ client .update_users ([{"id" : m } for m in members ])
172+ channel = client .channel (
173+ "team" , "beatles-" + str (uuid .uuid4 ()), {
174+ "members" : members ,
175+ "invites" : ["ringo" , "eric" ]
176+ })
177+ channel .create ("john" )
178+ # accept the invite when not a member
179+ with pytest .raises (StreamAPIException ):
180+ channel .accept_invite ("brian" )
181+ # accept the invite when a member
182+ accept = channel .accept_invite ("ringo" )
183+ for m in accept ['members' ]:
184+ if m ['user_id' ] == 'ringo' :
185+ assert m ['invited' ] is True
186+ assert "invite_accepted_at" in m
187+ # cannot accept again
188+ with pytest .raises (StreamAPIException ):
189+ channel .accept_invite ("ringo" )
190+ reject = channel .reject_invite ("eric" )
191+ for m in reject ['members' ]:
192+ if m ['user_id' ] == 'eric' :
193+ assert m ['invited' ] is True
194+ assert "invite_rejected_at" in m
195+ # cannot reject again
196+ with pytest .raises (StreamAPIException ):
197+ reject = channel .reject_invite ("eric" )
0 commit comments