@@ -27,9 +27,14 @@ def test_list_channel_types(self, client):
2727 response = client .list_channel_types ()
2828 assert "channel_types" in response
2929
30+ def test_update_channel_type (self , client ):
31+ response = client .update_channel_type ("team" , commands = ["ban" , "unban" ])
32+ assert "commands" in response
33+ assert response ["commands" ] == ["ban" , "unban" ]
34+
3035 def test_create_token (self , client ):
3136 token = client .create_token ("tommaso" )
32- payload = jwt .decode (token , client .api_secret , algorithm = "HS256" )
37+ payload = jwt .decode (token , client .api_secret , algorithms = [ "HS256" ] )
3338 assert payload .get ("user_id" ) == "tommaso"
3439
3540 def test_get_app_settings (self , client ):
@@ -48,6 +53,21 @@ def test_update_users(self, client):
4853 assert "users" in response
4954 assert user ["id" ] in response ["users" ]
5055
56+ def test_update_user_partial (self , client ):
57+ user_id = str (uuid .uuid4 ())
58+ client .update_user ({"id" : user_id , "field" : "value" })
59+
60+ response = client .update_user_partial ({
61+ "id" : user_id ,
62+ "set" : {
63+ "field" : "updated"
64+ }
65+ })
66+
67+ assert "users" in response
68+ assert user_id in response ["users" ]
69+ assert response ["users" ][user_id ]["field" ] == "updated"
70+
5171 def test_delete_user (self , client , random_user ):
5272 response = client .delete_user (random_user ["id" ])
5373 assert "user" in response
@@ -58,6 +78,14 @@ def test_deactivate_user(self, client, random_user):
5878 assert "user" in response
5979 assert random_user ["id" ] == response ["user" ]["id" ]
6080
81+ def test_reactivate_user (self , client , random_user ):
82+ response = client .deactivate_user (random_user ["id" ])
83+ assert "user" in response
84+ assert random_user ["id" ] == response ["user" ]["id" ]
85+ response = client .reactivate_user (random_user ["id" ])
86+ assert "user" in response
87+ assert random_user ["id" ] == response ["user" ]["id" ]
88+
6189 def test_export_user (self , client , fellowship_of_the_ring ):
6290 response = client .export_user ("gandalf" )
6391 assert "user" in response
@@ -99,6 +127,9 @@ def test_delete_message(self, client, channel, random_user):
99127 msg_id = str (uuid .uuid4 ())
100128 channel .send_message ({"id" : msg_id , "text" : "helloworld" }, random_user ["id" ])
101129 client .delete_message (msg_id )
130+ msg_id = str (uuid .uuid4 ())
131+ channel .send_message ({"id" : msg_id , "text" : "helloworld" }, random_user ["id" ])
132+ resp = client .delete_message (msg_id , hard = True )
102133
103134 def test_flag_message (self , client , channel , random_user , server_user ):
104135 msg_id = str (uuid .uuid4 ())
@@ -116,12 +147,6 @@ def test_query_users_young_hobbits(self, client, fellowship_of_the_ring):
116147 assert len (response ["users" ]) == 4
117148 assert [50 , 38 , 36 , 28 ] == [u ["age" ] for u in response ["users" ]]
118149
119- def test_query_channels_members_in (self , client , fellowship_of_the_ring ):
120- response = client .query_channels ({"members" : {"$in" : ["gimli" ]}}, {"id" : 1 })
121- assert len (response ["channels" ]) == 1
122- assert response ["channels" ][0 ]["channel" ]["id" ] == "fellowship-of-the-ring"
123- assert len (response ["channels" ][0 ]["members" ]) == 9
124-
125150 def test_devices (self , client , random_user ):
126151 response = client .get_devices (random_user ["id" ])
127152 assert "devices" in response
@@ -135,3 +160,29 @@ def test_devices(self, client, random_user):
135160 client .add_device (str (uuid .uuid4 ()), "apn" , random_user ["id" ])
136161 response = client .get_devices (random_user ["id" ])
137162 assert len (response ["devices" ]) == 1
163+
164+ def test_search (self , client , channel , random_user ):
165+ query = "supercalifragilisticexpialidocious"
166+ channel .send_message ({"text" : "How many syllables are there in {}?" .format (query )}, random_user ['id' ])
167+ channel .send_message ({"text" : "Does 'cious' count as one or two?" }, random_user ['id' ])
168+ response = client .search (
169+ {"type" : "messaging" },
170+ query ,
171+ ** {"limit" : 2 , "offset" : 0 }
172+ )
173+ # searches all channels so make sure at least one is found
174+ assert len (response ['results' ]) >= 1
175+ assert query in response ['results' ][0 ]['message' ]['text' ]
176+ response = client .search (
177+ {"type" : "messaging" },
178+ "cious" ,
179+ ** {"limit" : 12 , "offset" : 0 })
180+ for message in response ['results' ]:
181+ assert query not in message ['message' ]['text' ]
182+
183+ def test_query_channels_members_in (self , client , fellowship_of_the_ring ):
184+ response = client .query_channels ({"members" : {"$in" : ["gimli" ]}}, {"id" : 1 })
185+ assert len (response ["channels" ]) == 1
186+ assert response ["channels" ][0 ]["channel" ]["id" ] == "fellowship-of-the-ring"
187+ assert len (response ["channels" ][0 ]["members" ]) == 9
188+
0 commit comments