def test_is_user_course_or_global_staff(self): """ Test that is_user_course_or_global_staff function correctly returns whether a user is either global staff or course staff. """ user = User.objects.create( email='*****@*****.**', username='******' ) course_id = self.attempt['proctored_exam']['course_id'] # course_staff = true, is_staff = false # by default, user.is_staff is false and instructor_service.is_course_staff returns true self.assertTrue(is_user_course_or_global_staff(user, course_id)) # course_staff = true, is_staff = true user.is_staff = True self.assertTrue(is_user_course_or_global_staff(user, course_id)) # mock instructor service must be configured to treat users as not course staff. set_runtime_service('instructor', MockInstructorService(is_user_course_staff=False)) # course_staff = false, is_staff = true self.assertTrue(is_user_course_or_global_staff(user, course_id)) # course_staff = false, is_staff = false user.is_staff = False self.assertFalse(is_user_course_or_global_staff(user, course_id))
def setUp(self): super(ReviewTests, self).setUp() self.dummy_request = RequestFactory().get('/') self.exam_creation_params = { 'course_id': 'foo/bar/baz', 'content_id': 'content', 'exam_name': 'Sample Exam', 'time_limit_mins': 10, 'is_proctored': True, 'backend': 'test' } self.exam_id = create_exam(**self.exam_creation_params) self.attempt_id = create_exam_attempt( self.exam_id, self.user.id, taking_as_proctored=True ) self.attempt = get_exam_attempt_by_id(self.attempt_id) set_runtime_service('credit', MockCreditService()) set_runtime_service('instructor', MockInstructorService()) set_runtime_service('grades', MockGradesService()) set_runtime_service('certificates', MockCertificateService()) set_current_request(self.dummy_request)
def setUp(self): """ Initialize """ super(SoftwareSecureTests, self).setUp() self.user = User(username='******', email='*****@*****.**') self.user.save() set_runtime_service('credit', MockCreditService()) set_runtime_service('instructor', MockInstructorService())
def setUp(self): """ Initialize """ super().setUp() self.user = User(username='******', email='*****@*****.**') self.user.save() set_runtime_service('credit', MockCreditService()) set_runtime_service('instructor', MockInstructorService()) set_runtime_service('grades', MockGradesService()) set_runtime_service('certificates', MockCertificateService())
def setUp(self): super(ReviewTests, self).setUp() self.dummy_request = RequestFactory().get('/') self.exam_id = create_exam(course_id='foo/bar/baz', content_id='content', exam_name='Sample Exam', time_limit_mins=10, is_proctored=True, backend='test') self.attempt_id = create_exam_attempt(self.exam_id, self.user.id, taking_as_proctored=True) self.attempt = get_exam_attempt_by_id(self.attempt_id) set_runtime_service('credit', MockCreditService()) set_runtime_service('instructor', MockInstructorService()) set_runtime_service('grades', MockGradesService()) set_runtime_service('certificates', MockCertificateService()) set_current_request(self.dummy_request)
def setUp(self): """ Build up test data """ super().setUp() set_runtime_service('credit', MockCreditService()) set_runtime_service('grades', MockGradesService()) set_runtime_service('certificates', MockCertificateService()) set_runtime_service('instructor', MockInstructorService()) self.exam_id = create_exam(course_id='foo', content_id='bar', exam_name='Test Exam', time_limit_mins=90) ProctoredExamStudentAttempt.objects.create( proctored_exam_id=self.exam_id, user_id=self.user.id, external_id='foo', started_at=datetime.now(pytz.UTC), status=ProctoredExamStudentAttemptStatus.started, allowed_time_limit_mins=10, taking_as_proctored=True, is_sample_attempt=False)
def setUp(self): """ Build out test harnessing """ super(ProctoredExamTestCase, self).setUp() self.default_time_limit = 21 self.course_id = 'a/b/c' self.content_id_for_exam_with_due_date = 'test_content_due_date_id' self.content_id = 'test_content_id' self.content_id_timed = 'test_content_id_timed' self.content_id_practice = 'test_content_id_practice' self.content_id_onboarding = 'test_content_id_onboarding' self.disabled_content_id = 'test_disabled_content_id' self.exam_name = 'Test Exam' self.user_id = self.user.id self.key = 'additional_time_granted' self.value = '10' self.external_id = 'test_external_id' self.proctored_exam_id = self._create_proctored_exam() self.timed_exam_id = self._create_timed_exam() self.practice_exam_id = self._create_practice_exam() self.onboarding_exam_id = self._create_onboarding_exam() self.disabled_exam_id = self._create_disabled_exam() set_runtime_service('credit', MockCreditService()) set_runtime_service('instructor', MockInstructorService(is_user_course_staff=True)) tracker.register_tracker(MockTracker()) self.prerequisites = [ { 'namespace': 'proctoring', 'name': 'proc1', 'order': 2, 'status': 'satisfied', }, { 'namespace': 'reverification', 'name': 'rever1', 'order': 1, 'status': 'satisfied', }, { 'namespace': 'grade', 'name': 'grade1', 'order': 0, 'status': 'pending', }, { 'namespace': 'reverification', 'name': 'rever2', 'order': 3, 'status': 'failed', }, { 'namespace': 'proctoring', 'name': 'proc2', 'order': 4, 'status': 'pending', }, ] self.declined_prerequisites = [ { 'namespace': 'proctoring', 'name': 'proc1', 'order': 2, 'status': 'satisfied', }, { 'namespace': 'reverification', 'name': 'rever1', 'order': 1, 'status': 'satisfied', }, { 'namespace': 'grade', 'name': 'grade1', 'order': 0, 'status': 'pending', }, { 'namespace': 'reverification', 'name': 'rever2', 'order': 3, 'status': 'declined', }, { 'namespace': 'proctoring', 'name': 'proc2', 'order': 4, 'status': 'pending', }, ]