def test_not_found_across_course(self): # This ensure course is filtered another_participation = factories.ParticipationFactory( course=factories.CourseFactory(identifier="another-course")) with self.assertRaises(grades.ParticipantNotFound): grades.find_participant_from_id(self.course, another_participation.user.email)
def test_skip_not_active(self): dropped_participation = factories.ParticipationFactory( course=self.course, status=constants.participation_status.dropped) with self.assertRaises(grades.ParticipantNotFound) as cm: grades.find_participant_from_id(self.course, dropped_participation.user.email) expected_error_msg = ("no participant found for '%s'" % dropped_participation.user.email) self.assertIn(expected_error_msg, str(cm.exception))
def test_found_multiple(self): email = self.student_participation.user.email at_index = email.index("@") uid = email[:at_index] # create another participation with the same uid factories.ParticipationFactory( course=self.course, user=factories.UserFactory(email="*****@*****.**" % uid.upper())) with self.assertRaises(grades.ParticipantNotFound) as cm: grades.find_participant_from_id(self.course, uid) expected_error_msg = "more than one participant found for '%s'" % uid self.assertIn(expected_error_msg, str(cm.exception))
def test_not_found_email_not_match_exactly(self): idstr = self.student_participation.user.email.replace(".com", "") with self.assertRaises(grades.ParticipantNotFound) as cm: grades.find_participant_from_id(self.course, idstr) expected_error_msg = "no participant found for '%s'" % idstr self.assertIn(expected_error_msg, str(cm.exception))
def test_not_found(self): with self.assertRaises(grades.ParticipantNotFound) as cm: grades.find_participant_from_id(self.course, "*****@*****.**") expected_error_msg = "no participant found for '*****@*****.**'" self.assertIn(expected_error_msg, str(cm.exception))
def test_found_by_id(self): email = self.student_participation.user.email at_index = email.index("@") uid = email[:at_index].upper() self.assertEqual(grades.find_participant_from_id(self.course, uid), self.student_participation)
def test_found_iexact(self): self.assertEqual( grades.find_participant_from_id( self.course, self.student_participation.user.email.upper()), self.student_participation)