@@ -41,9 +41,7 @@ class TestViews(TestCase):
41
41
42
42
@classmethod
43
43
def setUpTestData (cls ):
44
- cls .user : User = User .objects .create_user (
45
- "test" ,
"[email protected] " ,
"password"
46
- )
44
+ cls .
user :
User = User .
objects .
create_user (
"test" ,
"[email protected] " ,
"password" )
47
45
cls .user .is_staff = True
48
46
cls .user .save ()
49
47
cls .user_profile : UserProfile = UserProfile (user = cls .user )
@@ -235,9 +233,7 @@ def test_connection_parameters_api_call_returns_404_for_logged_out_user(self):
235
233
self .game .can_play .set ([user ])
236
234
self .game .save ()
237
235
238
- first_response = client_one .get (
239
- reverse ("kurono/connection_parameters" , kwargs = {"game_id" : 1 })
240
- )
236
+ first_response = client_one .get (reverse ("kurono/connection_parameters" , kwargs = {"game_id" : 1 }))
241
237
242
238
assert first_response .status_code == 403
243
239
@@ -253,9 +249,7 @@ def test_id_of_connection_parameters_same_as_games_url(self):
253
249
connection_parameters_response = client .get (
254
250
reverse ("kurono/connection_parameters" , kwargs = {"game_id" : 1 })
255
251
).json ()
256
- games_api_response = client .get (
257
- reverse ("kurono/game_user_details" , kwargs = {"id" : 1 })
258
- )
252
+ games_api_response = client .get (reverse ("kurono/game_user_details" , kwargs = {"id" : 1 }))
259
253
260
254
current_avatar_id = connection_parameters_response ["avatar_id" ]
261
255
games_api_users = json .loads (games_api_response .content )["users" ]
@@ -295,9 +289,7 @@ def test_get_token_after_token_set(self):
295
289
)
296
290
297
291
# Token starts as empty, as long as it is empty, we can make more GET requests
298
- response = client .get (
299
- reverse ("kurono/game_token" , kwargs = {"id" : 1 }), HTTP_GAME_TOKEN = new_token
300
- )
292
+ response = client .get (reverse ("kurono/game_token" , kwargs = {"id" : 1 }), HTTP_GAME_TOKEN = new_token )
301
293
assert response .status_code == status .HTTP_200_OK
302
294
303
295
def test_patch_token_with_no_token (self ):
@@ -372,9 +364,7 @@ def test_delete_game(self):
372
364
assert game3 .game_class == klass
373
365
374
366
# test only one active game at a time
375
- assert (
376
- models .Game .objects .filter (game_class = klass , is_archived = False ).count () == 1
377
- )
367
+ assert models .Game .objects .filter (game_class = klass , is_archived = False ).count () == 1
378
368
379
369
def test_delete_non_existent_game (self ):
380
370
c = self .login ()
@@ -398,10 +388,7 @@ def test_game_serializer_settings(self):
398
388
399
389
serializer = GameSerializer (self .game )
400
390
401
- assert (
402
- json .dumps (self .game .settings_as_dict (), sort_keys = True )
403
- == serializer .data ["settings" ]
404
- )
391
+ assert json .dumps (self .game .settings_as_dict (), sort_keys = True ) == serializer .data ["settings" ]
405
392
406
393
def test_list_all_games (self ):
407
394
self .game .main_user = self .user
@@ -492,16 +479,12 @@ def test_update_game_worksheet_updates_avatar_codes(self, mock_game_manager):
492
479
493
480
def test_delete_games (self ):
494
481
# Create a new teacher with a game to make sure it's not affected
495
- new_user : User = User .objects .create_user (
496
- "test2" ,
"[email protected] " ,
"password"
497
- )
482
+ new_user :
User = User .
objects .
create_user (
"test2" ,
"[email protected] " ,
"password" )
498
483
new_user .is_staff = True
499
484
new_user .save ()
500
485
new_user_profile : UserProfile = UserProfile (user = new_user )
501
486
new_user_profile .save ()
502
- new_teacher : Teacher = Teacher .objects .create (
503
- user = new_user_profile , new_user = new_user
504
- )
487
+ new_teacher : Teacher = Teacher .objects .create (user = new_user_profile , new_user = new_user )
505
488
new_teacher .save ()
506
489
new_klass , _ , _ = create_class_directly (new_user .email )
507
490
new_user .save ()
@@ -515,12 +498,8 @@ def test_delete_games(self):
515
498
data = {"game_ids" : [self .game .id , game2 .id , new_game .id ]}
516
499
517
500
# Try to login as a student and delete games - they shouldn't have access
518
- _ , student_password , student = create_school_student_directly (
519
- self .klass .access_code
520
- )
521
- client = self .login (
522
- username = student .new_user .username , password = student_password
523
- )
501
+ _ , student_password , student = create_school_student_directly (self .klass .access_code )
502
+ client = self .login (username = student .new_user .username , password = student_password )
524
503
response = client .post (reverse ("game-delete-games" ), data )
525
504
assert response .status_code == 403
526
505
assert Game .objects .filter (is_archived = False ).count () == 3
0 commit comments