def test_assignments(self):
     assignments = get_assignments(submissions=get_submissions(),
                                   judge_profiles=get_judge_profiles(),
                                   commit=False)
     self.assertEvenAssignment(assignments)
     # Check nothing has been saved
     self.assertEqual(JudgeAssignment.objects.count(), 0)
 def test_assignment_commit(self):
     assignments = get_assignments(submissions=get_submissions(),
                                   judge_profiles=get_judge_profiles(),
                                   commit=True)
     self.assertEvenAssignment(assignments)
     expected_submissions = (settings.JUDGES_PER_SUBMISSION *
                             Submission.objects.count())
     self.assertEqual(JudgeAssignment.objects.count(),
                      expected_submissions)
 def test_judge_group(self):
     """Test that judges with permission through a group are included."""
     judges = Group.objects.create(name='Judges')
     judges.permissions.add(self.judging_permission)
     for user in User.objects.filter(username__in=['alex', 'charlie']):
         user.user_permissions.clear()
         if user.username == 'charlie':
             user.groups.add(judges)
     self.assertEqual(set([j.user.username for j in get_judge_profiles()]),
                      set(['charlie']))
 def test_get_judges_superuser(self):
     """Test superusers aren't automatically returned as judges."""
     User.objects.filter(username='******').update(is_superuser=True)
     self.assertEqual(set([j.user.username for j in get_judge_profiles()]),
                      set(['alex', 'charlie']))
 def test_get_judges(self):
     self.assertEqual(set([j.user.username for j in get_judge_profiles()]),
                      set(['alex', 'charlie']))