def test_run_comand(self): """ Run the management command """ set_attempt_status.Command().handle( exam_id=self.exam_id, user_id=self.user.id, to_status=ProctoredExamStudentAttemptStatus.rejected ) attempt = get_exam_attempt(self.exam_id, self.user.id) self.assertEqual(attempt["status"], ProctoredExamStudentAttemptStatus.rejected) set_attempt_status.Command().handle( exam_id=self.exam_id, user_id=self.user.id, to_status=ProctoredExamStudentAttemptStatus.verified ) attempt = get_exam_attempt(self.exam_id, self.user.id) self.assertEqual(attempt["status"], ProctoredExamStudentAttemptStatus.verified)
def test_run_comand(self): """ Run the management command """ set_attempt_status.Command().handle( exam_id=self.exam_id, user_id=self.user.id, to_status=ProctoredExamStudentAttemptStatus.rejected) attempt = get_exam_attempt(self.exam_id, self.user.id) self.assertEqual(attempt['status'], ProctoredExamStudentAttemptStatus.rejected) set_attempt_status.Command().handle( exam_id=self.exam_id, user_id=self.user.id, to_status=ProctoredExamStudentAttemptStatus.verified) attempt = get_exam_attempt(self.exam_id, self.user.id) self.assertEqual(attempt['status'], ProctoredExamStudentAttemptStatus.verified)
def test_prereq_scenarios(self, namespace, req_status, expected_content, should_see_prereq): """ This test asserts that proctoring will not be displayed under the following conditions: - Verified student has not completed all 'reverification' requirements """ # user hasn't attempted reverifications rendered_response = self.render_proctored_exam({ 'credit_state': { 'enrollment_mode': 'verified', 'credit_requirement_status': [{ 'namespace': namespace, 'name': 'foo', 'display_name': 'Foo Requirement', 'status': req_status, 'order': 0 }] }, }) if expected_content: self.assertIn(expected_content, rendered_response) else: self.assertIsNone(rendered_response) if req_status == 'declined' and not expected_content: # also we should have auto-declined if a pre-requisite was declined attempt = get_exam_attempt(self.proctored_exam_id, self.user_id) self.assertIsNotNone(attempt) self.assertEqual(attempt['status'], ProctoredExamStudentAttemptStatus.declined) if should_see_prereq: self.assertIn('Foo Requirement', rendered_response)
def test_prereq_scenarios(self, namespace, req_status, expected_content, should_see_prereq): """ This test asserts that proctoring will not be displayed under the following conditions: - Verified student has not completed all 'reverification' requirements """ # user hasn't attempted reverifications rendered_response = self.render_proctored_exam({ 'credit_state': { 'enrollment_mode': 'verified', 'credit_requirement_status': [ { 'namespace': namespace, 'name': 'foo', 'display_name': 'Foo Requirement', 'status': req_status, 'order': 0 } ] }, }) if expected_content: self.assertIn(expected_content, rendered_response) else: self.assertIsNone(rendered_response) if req_status == 'declined' and not expected_content: # also we should have auto-declined if a pre-requisite was declined attempt = get_exam_attempt(self.proctored_exam_id, self.user_id) self.assertIsNotNone(attempt) self.assertEqual(attempt['status'], ProctoredExamStudentAttemptStatus.declined) if should_see_prereq: self.assertIn('Foo Requirement', rendered_response)