def test_get_exam_card_status_for_edx_exams(self, profile_status, expected_status, make_exam_run, make_profile, make_auth): """ test get_exam_card_status """ now = now_in_utc() exam_run = None if make_exam_run: exam_run = ExamRunFactory.create( course=self.course, date_first_eligible=now - timedelta(weeks=1), date_last_eligible=now + timedelta(weeks=1), ) if make_profile: ExamProfileFactory.create( profile=self.user.profile, status=profile_status, ) if make_auth: ExamAuthorizationFactory.create( user=self.user, status=ExamAuthorization.STATUS_SUCCESS, exam_run=exam_run, ) mmtrack = MMTrack( user=self.user, program=self.program, edx_user_data=self.cached_edx_user_data ) assert mmtrack.get_exam_card_status() == expected_status
def test_get_exam_card_status_eligible(self): """ test get_exam_card_status against valid eligibility dates """ ExamProfileFactory.create( profile=self.user.profile, status=ExamProfile.PROFILE_SUCCESS, ) now = datetime(2016, 3, 15, tzinfo=pytz.UTC) past = datetime(2016, 3, 10, tzinfo=pytz.UTC) future = datetime(2016, 3, 20, tzinfo=pytz.UTC) valid_dates = [ past - timedelta(days=1), past, now, future, ] invalid_dates = [ future + timedelta(days=1), ] ExamAuthorizationFactory.create( user=self.user, status=ExamAuthorization.STATUS_SUCCESS, exam_run__course=self.course, exam_run__date_first_eligible=past.date(), exam_run__date_last_eligible=future.date(), ) mmtrack = MMTrack( user=self.user, program=self.program, edx_user_data=self.cached_edx_user_data ) # should be considered schedulable if past <= datetime.now() <= future for now_value in valid_dates: mmtrack.now = now_value assert mmtrack.get_exam_card_status() == ExamProfile.PROFILE_SCHEDULABLE # not eligible for now_value in invalid_dates: mmtrack.now = now_value assert mmtrack.get_exam_card_status() == ExamProfile.PROFILE_SUCCESS