12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- import json
16
15
import urllib .parse
17
16
from http import HTTPStatus
18
17
from typing import List , Optional
@@ -118,12 +117,11 @@ def test_new_room_user_does_not_exist(self):
118
117
"""
119
118
Tests that the user ID must be from local server but it does not have to exist.
120
119
"""
121
- body = json .dumps ({"new_room_user_id" : "@unknown:test" })
122
120
123
121
channel = self .make_request (
124
122
"DELETE" ,
125
123
self .url ,
126
- content = body ,
124
+ content = { "new_room_user_id" : "@unknown:test" } ,
127
125
access_token = self .admin_user_tok ,
128
126
)
129
127
@@ -137,12 +135,11 @@ def test_new_room_user_is_not_local(self):
137
135
"""
138
136
Check that only local users can create new room to move members.
139
137
"""
140
- body = json .dumps ({"new_room_user_id" : "@not:exist.bla" })
141
138
142
139
channel = self .make_request (
143
140
"DELETE" ,
144
141
self .url ,
145
- content = body ,
142
+ content = { "new_room_user_id" : "@not:exist.bla" } ,
146
143
access_token = self .admin_user_tok ,
147
144
)
148
145
@@ -156,12 +153,11 @@ def test_block_is_not_bool(self):
156
153
"""
157
154
If parameter `block` is not boolean, return an error
158
155
"""
159
- body = json .dumps ({"block" : "NotBool" })
160
156
161
157
channel = self .make_request (
162
158
"DELETE" ,
163
159
self .url ,
164
- content = body ,
160
+ content = { "block" : "NotBool" } ,
165
161
access_token = self .admin_user_tok ,
166
162
)
167
163
@@ -172,12 +168,11 @@ def test_purge_is_not_bool(self):
172
168
"""
173
169
If parameter `purge` is not boolean, return an error
174
170
"""
175
- body = json .dumps ({"purge" : "NotBool" })
176
171
177
172
channel = self .make_request (
178
173
"DELETE" ,
179
174
self .url ,
180
- content = body ,
175
+ content = { "purge" : "NotBool" } ,
181
176
access_token = self .admin_user_tok ,
182
177
)
183
178
@@ -198,12 +193,10 @@ def test_purge_room_and_block(self):
198
193
# Assert one user in room
199
194
self ._is_member (room_id = self .room_id , user_id = self .other_user )
200
195
201
- body = json .dumps ({"block" : True , "purge" : True })
202
-
203
196
channel = self .make_request (
204
197
"DELETE" ,
205
198
self .url .encode ("ascii" ),
206
- content = body ,
199
+ content = { "block" : True , "purge" : True } ,
207
200
access_token = self .admin_user_tok ,
208
201
)
209
202
@@ -231,12 +224,10 @@ def test_purge_room_and_not_block(self):
231
224
# Assert one user in room
232
225
self ._is_member (room_id = self .room_id , user_id = self .other_user )
233
226
234
- body = json .dumps ({"block" : False , "purge" : True })
235
-
236
227
channel = self .make_request (
237
228
"DELETE" ,
238
229
self .url .encode ("ascii" ),
239
- content = body ,
230
+ content = { "block" : False , "purge" : True } ,
240
231
access_token = self .admin_user_tok ,
241
232
)
242
233
@@ -265,12 +256,10 @@ def test_block_room_and_not_purge(self):
265
256
# Assert one user in room
266
257
self ._is_member (room_id = self .room_id , user_id = self .other_user )
267
258
268
- body = json .dumps ({"block" : True , "purge" : False })
269
-
270
259
channel = self .make_request (
271
260
"DELETE" ,
272
261
self .url .encode ("ascii" ),
273
- content = body ,
262
+ content = { "block" : True , "purge" : False } ,
274
263
access_token = self .admin_user_tok ,
275
264
)
276
265
@@ -342,7 +331,7 @@ def test_shutdown_room_consent(self):
342
331
channel = self .make_request (
343
332
"DELETE" ,
344
333
self .url ,
345
- json . dumps ( {"new_room_user_id" : self .admin_user }) ,
334
+ {"new_room_user_id" : self .admin_user },
346
335
access_token = self .admin_user_tok ,
347
336
)
348
337
@@ -372,7 +361,7 @@ def test_shutdown_room_block_peek(self):
372
361
channel = self .make_request (
373
362
"PUT" ,
374
363
url .encode ("ascii" ),
375
- json . dumps ( {"history_visibility" : "world_readable" }) ,
364
+ {"history_visibility" : "world_readable" },
376
365
access_token = self .other_user_tok ,
377
366
)
378
367
self .assertEqual (HTTPStatus .OK , channel .code , msg = channel .json_body )
@@ -388,7 +377,7 @@ def test_shutdown_room_block_peek(self):
388
377
channel = self .make_request (
389
378
"DELETE" ,
390
379
self .url ,
391
- json . dumps ( {"new_room_user_id" : self .admin_user }) ,
380
+ {"new_room_user_id" : self .admin_user },
392
381
access_token = self .admin_user_tok ,
393
382
)
394
383
@@ -1782,12 +1771,11 @@ def test_requester_is_no_admin(self):
1782
1771
"""
1783
1772
If the user is not a server admin, an error HTTPStatus.FORBIDDEN is returned.
1784
1773
"""
1785
- body = json .dumps ({"user_id" : self .second_user_id })
1786
1774
1787
1775
channel = self .make_request (
1788
1776
"POST" ,
1789
1777
self .url ,
1790
- content = body ,
1778
+ content = { "user_id" : self . second_user_id } ,
1791
1779
access_token = self .second_tok ,
1792
1780
)
1793
1781
@@ -1798,12 +1786,11 @@ def test_invalid_parameter(self):
1798
1786
"""
1799
1787
If a parameter is missing, return an error
1800
1788
"""
1801
- body = json .dumps ({"unknown_parameter" : "@unknown:test" })
1802
1789
1803
1790
channel = self .make_request (
1804
1791
"POST" ,
1805
1792
self .url ,
1806
- content = body ,
1793
+ content = { "unknown_parameter" : "@unknown:test" } ,
1807
1794
access_token = self .admin_user_tok ,
1808
1795
)
1809
1796
@@ -1814,12 +1801,11 @@ def test_local_user_does_not_exist(self):
1814
1801
"""
1815
1802
Tests that a lookup for a user that does not exist returns a HTTPStatus.NOT_FOUND
1816
1803
"""
1817
- body = json .dumps ({"user_id" : "@unknown:test" })
1818
1804
1819
1805
channel = self .make_request (
1820
1806
"POST" ,
1821
1807
self .url ,
1822
- content = body ,
1808
+ content = { "user_id" : "@unknown:test" } ,
1823
1809
access_token = self .admin_user_tok ,
1824
1810
)
1825
1811
@@ -1830,12 +1816,11 @@ def test_remote_user(self):
1830
1816
"""
1831
1817
Check that only local user can join rooms.
1832
1818
"""
1833
- body = json .dumps ({"user_id" : "@not:exist.bla" })
1834
1819
1835
1820
channel = self .make_request (
1836
1821
"POST" ,
1837
1822
self .url ,
1838
- content = body ,
1823
+ content = { "user_id" : "@not:exist.bla" } ,
1839
1824
access_token = self .admin_user_tok ,
1840
1825
)
1841
1826
@@ -1849,13 +1834,12 @@ def test_room_does_not_exist(self):
1849
1834
"""
1850
1835
Check that unknown rooms/server return error HTTPStatus.NOT_FOUND.
1851
1836
"""
1852
- body = json .dumps ({"user_id" : self .second_user_id })
1853
1837
url = "/_synapse/admin/v1/join/!unknown:test"
1854
1838
1855
1839
channel = self .make_request (
1856
1840
"POST" ,
1857
1841
url ,
1858
- content = body ,
1842
+ content = { "user_id" : self . second_user_id } ,
1859
1843
access_token = self .admin_user_tok ,
1860
1844
)
1861
1845
@@ -1866,13 +1850,12 @@ def test_room_is_not_valid(self):
1866
1850
"""
1867
1851
Check that invalid room names, return an error HTTPStatus.BAD_REQUEST.
1868
1852
"""
1869
- body = json .dumps ({"user_id" : self .second_user_id })
1870
1853
url = "/_synapse/admin/v1/join/invalidroom"
1871
1854
1872
1855
channel = self .make_request (
1873
1856
"POST" ,
1874
1857
url ,
1875
- content = body ,
1858
+ content = { "user_id" : self . second_user_id } ,
1876
1859
access_token = self .admin_user_tok ,
1877
1860
)
1878
1861
@@ -1886,12 +1869,11 @@ def test_join_public_room(self):
1886
1869
"""
1887
1870
Test joining a local user to a public room with "JoinRules.PUBLIC"
1888
1871
"""
1889
- body = json .dumps ({"user_id" : self .second_user_id })
1890
1872
1891
1873
channel = self .make_request (
1892
1874
"POST" ,
1893
1875
self .url ,
1894
- content = body ,
1876
+ content = { "user_id" : self . second_user_id } ,
1895
1877
access_token = self .admin_user_tok ,
1896
1878
)
1897
1879
@@ -1917,12 +1899,11 @@ def test_join_private_room_if_not_member(self):
1917
1899
self .creator , tok = self .creator_tok , is_public = False
1918
1900
)
1919
1901
url = f"/_synapse/admin/v1/join/{ private_room_id } "
1920
- body = json .dumps ({"user_id" : self .second_user_id })
1921
1902
1922
1903
channel = self .make_request (
1923
1904
"POST" ,
1924
1905
url ,
1925
- content = body ,
1906
+ content = { "user_id" : self . second_user_id } ,
1926
1907
access_token = self .admin_user_tok ,
1927
1908
)
1928
1909
@@ -1960,12 +1941,11 @@ def test_join_private_room_if_member(self):
1960
1941
# Join user to room.
1961
1942
1962
1943
url = f"/_synapse/admin/v1/join/{ private_room_id } "
1963
- body = json .dumps ({"user_id" : self .second_user_id })
1964
1944
1965
1945
channel = self .make_request (
1966
1946
"POST" ,
1967
1947
url ,
1968
- content = body ,
1948
+ content = { "user_id" : self . second_user_id } ,
1969
1949
access_token = self .admin_user_tok ,
1970
1950
)
1971
1951
self .assertEqual (HTTPStatus .OK , channel .code , msg = channel .json_body )
@@ -1990,12 +1970,11 @@ def test_join_private_room_if_owner(self):
1990
1970
self .admin_user , tok = self .admin_user_tok , is_public = False
1991
1971
)
1992
1972
url = f"/_synapse/admin/v1/join/{ private_room_id } "
1993
- body = json .dumps ({"user_id" : self .second_user_id })
1994
1973
1995
1974
channel = self .make_request (
1996
1975
"POST" ,
1997
1976
url ,
1998
- content = body ,
1977
+ content = { "user_id" : self . second_user_id } ,
1999
1978
access_token = self .admin_user_tok ,
2000
1979
)
2001
1980
0 commit comments