22
33from django .contrib .auth import get_user_model
44from django .core .files .uploadedfile import SimpleUploadedFile
5- from django .test import override_settings
65from django .urls import reverse
76from django .utils import timezone
87
@@ -255,7 +254,6 @@ def test_eighth_admin_signup_group(self):
255254 for user in [user1 , user2 , user3 ]:
256255 self .assertEqual (1 , EighthSignup .objects .filter (user = user , scheduled_activity = scheduled ).count ())
257256
258- @override_settings (ALLOWED_HOSTS = ["testserver" , "localhost" , "127.0.0.1" ])
259257 def test_eighth_admin_distribute_group (self ):
260258 """Tests :func:`~intranet.apps.eighth.views.admin.groups.eighth_admin_distribute_group` - the wizard only."""
261259
@@ -369,8 +367,10 @@ def test_eighth_admin_distribute_unsigned(self):
369367 response = self .client .post (
370368 reverse ("eighth_admin_distribute_unsigned" ), data = {"eighth_admin_distribute_group_wizard-current_step" : "block" , "block-block" : block .id }
371369 )
370+ test_users = [user1 , user2 , user3 ]
371+ context_users = list (response .context ["users" ])
372372 self .assertEqual (200 , response .status_code )
373- self .assertEqual ([ user1 , user2 , user3 ], list ( response . context [ "users" ] ))
373+ self .assertEqual (sorted ( test_users , key = lambda x : x . username ), sorted ( context_users , key = lambda x : x . username ))
374374
375375 # Select the two activities
376376 response = self .client .post (
@@ -432,10 +432,11 @@ def test_eighth_admin_distribute_action(self):
432432
433433 # Load the page
434434 response = self .client .get (reverse ("eighth_admin_distribute_action" ), data = {"schact" : [scheduled1 .id , scheduled2 .id ], "group" : group .id })
435+ test_users = [user1 , user2 , user3 ]
435436 self .assertEqual (200 , response .status_code )
436437 self .assertEqual (group , response .context ["group" ])
437- self .assertEqual ([scheduled1 , scheduled2 ], list ( response .context ["schacts" ]) )
438- self .assertEqual ([ user1 , user2 , user3 ] , list (response .context ["users" ]))
438+ self .assertEqual ([scheduled1 , scheduled2 ], [ pair [ 0 ] for pair in response .context ["schacts" ]] )
439+ self .assertEqual (sorted ( test_users , key = lambda x : x . last_name ) , list (response .context ["users" ]))
439440
440441 # Perform a signup but manually specifying which user gets which activity
441442 response = self .client .post (
@@ -455,8 +456,10 @@ def test_eighth_admin_distribute_action(self):
455456 response = self .client .get (
456457 reverse ("eighth_admin_distribute_action" ), data = {"schact" : [scheduled1 .id , scheduled2 .id ], "unsigned" : True , "block" : block .id }
457458 )
459+ test_users = [user1 , user2 ]
460+ context_users = list (response .context ["users" ])
458461 self .assertEqual (200 , response .status_code )
459- self .assertEqual ([ user1 , user2 ], list ( response . context [ "users" ] ))
462+ self .assertEqual (sorted ( test_users , key = lambda x : x . username ), sorted ( context_users , key = lambda x : x . username ))
460463
461464 # Actually performing the signup is redundant
462465
0 commit comments