@@ -185,6 +185,73 @@ def test_list(client, room, room2, user, user2, admin, mod, global_mod, global_a
185
185
assert r .json == {** r4_expected , ** r4_exp_defs , ** exp_gadmin }
186
186
187
187
188
+ def test_visible_global_mods (client , room , user , mod , global_mod , global_admin ):
189
+ url_room = '/room/test-room'
190
+ expect_room = {
191
+ "token" : "test-room" ,
192
+ "name" : "Test room" ,
193
+ "description" : "Test suite testing room" ,
194
+ "info_updates" : 3 ,
195
+ "message_sequence" : 0 ,
196
+ "created" : room .created ,
197
+ "active_users" : 0 ,
198
+ "active_users_cutoff" : int (sogs .config .ROOM_DEFAULT_ACTIVE_THRESHOLD ),
199
+ "moderators" : [mod .session_id ],
200
+ "admins" : [],
201
+ "read" : True ,
202
+ "write" : True ,
203
+ "upload" : True ,
204
+ }
205
+ r = sogs_get (client , url_room , user )
206
+ assert r .status_code == 200
207
+ assert r .json == expect_room
208
+
209
+ expected_for_moderator = {
210
+ ** expect_room ,
211
+ ** {'default_' + x : True for x in ('accessible' , 'read' , 'write' , 'upload' )},
212
+ 'global_moderator' : True ,
213
+ 'hidden_admins' : [global_admin .session_id ],
214
+ 'hidden_moderators' : [global_mod .session_id ],
215
+ 'moderator' : True ,
216
+ 'moderators' : [mod .session_id ],
217
+ }
218
+ r = sogs_get (client , "/room/test-room/pollInfo/0" , global_mod )
219
+ assert r .status_code == 200
220
+ assert r .json == {
221
+ 'token' : 'test-room' ,
222
+ 'active_users' : 0 ,
223
+ 'details' : expected_for_moderator ,
224
+ 'read' : True ,
225
+ 'write' : True ,
226
+ 'upload' : True ,
227
+ 'moderator' : True ,
228
+ 'global_moderator' : True ,
229
+ 'default_accessible' : True ,
230
+ 'default_read' : True ,
231
+ 'default_write' : True ,
232
+ 'default_upload' : True ,
233
+ }
234
+
235
+ global_mod .set_moderator (added_by = global_admin , admin = False , visible = True )
236
+ global_admin .set_moderator (added_by = global_admin , admin = True , visible = True )
237
+
238
+ for e in (expect_room , expected_for_moderator ):
239
+ e ["moderators" ] = sorted ([mod .session_id , global_mod .session_id ])
240
+ e ["admins" ] = [global_admin .session_id ]
241
+ e ["info_updates" ] += 2
242
+ del expected_for_moderator ["hidden_admins" ]
243
+ del expected_for_moderator ["hidden_moderators" ]
244
+
245
+ r = sogs_get (client , url_room , user )
246
+ assert r .status_code == 200
247
+ assert r .json == expect_room
248
+
249
+ r = sogs_get (client , url_room , mod )
250
+ assert r .status_code == 200
251
+ del expected_for_moderator ["global_moderator" ]
252
+ assert r .json == expected_for_moderator
253
+
254
+
188
255
def test_updates (client , room , user , user2 , mod , admin , global_mod , global_admin ):
189
256
url_room = '/room/test-room'
190
257
r = sogs_get (client , url_room , user )
0 commit comments