Exemple #1
0
    def test_get_pearson_exam_status(self, profile_status, expected_status, make_exam_run,
                                     make_profile, make_auth, log_error_called, log_mock):
        """
        test get_pearson_exam_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_pearson_exam_status() == expected_status
        assert log_mock.error.called is log_error_called
Exemple #2
0
 def setUpTestData(cls):
     with mute_signals(post_save):
         # valid profiles
         cls.expected_in_progress_profiles = ExamProfileFactory.create_batch(5, status=ExamProfile.PROFILE_PENDING)
         # invalid profiles
         cls.expected_invalid_profiles = ExamProfileFactory.create_batch(5, status=ExamProfile.PROFILE_PENDING)
         cls.all_profiles = cls.expected_in_progress_profiles + cls.expected_invalid_profiles
Exemple #3
0
    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
Exemple #4
0
    def two_no_show_exam_attempts(self):
        """Passed and later failed course, and two exam attempts"""
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)

        course = Course.objects.get(title='Digital Learning 200')
        course_run = CourseRunFactory(course=course, edx_course_key='course-passed')
        call_command(
            "alter_data", 'set_to_passed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key
        )

        ExamProfileFactory.create(status='success', profile=self.user.profile)
        # run 1
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True, exam_no_show=True
        )
        # run 2
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True, exam_no_show=True
        )
        # another offered
        course_run = CourseRunFactory.create(course=course, edx_course_key='course-enrollable')
        call_command(
            "alter_data", 'set_to_offered', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key
        )
        course_run = CourseRunFactory.create(course=course, edx_course_key='course-failed')
        call_command(
            "alter_data", 'set_to_failed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key, '--audit',
        )
Exemple #5
0
    def create_missed_payment_for_exam(self, enrollable, future_exam, current):
        """Passed course but missed deadline to pay to take exam"""
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        if current:
            call_command(
                "alter_data", 'set_to_enrolled', '--username', 'staff',
                '--course-title', 'Digital Learning 200',
                '--missed-deadline'
            )
        else:
            call_command(
                "alter_data", 'set_past_run_to_passed', '--username', 'staff',
                '--course-title', 'Digital Learning 200', '--grade', '87', '--audit',
                '--missed-deadline'
            )
        course = Course.objects.get(title='Digital Learning 200')
        ExamProfileFactory.create(status='success', profile=self.user.profile)
        ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)

        if enrollable:
            course_run = CourseRunFactory.create(course=course, edx_course_key='course-enrollable')
            call_command(
                "alter_data", 'set_to_offered', '--username', 'staff',
                '--course-run-key', course_run.edx_course_key
            )
        if future_exam:
            ExamRunFactory.create(
                scheduling_past=False,
                scheduling_future=True,
                authorized=True,
                course=course
            )
 def setUpTestData(cls):
     with mute_signals(post_save):
         # valid profiles
         cls.expected_in_progress_profiles = ExamProfileFactory.create_batch(
             5, status=ExamProfile.PROFILE_PENDING)
         # invalid profiles
         cls.expected_invalid_profiles = ExamProfileFactory.create_batch(
             5, status=ExamProfile.PROFILE_PENDING)
         cls.all_profiles = cls.expected_in_progress_profiles + cls.expected_invalid_profiles
    def test_write_cdd_file(self):
        """
        Tests cdd_writer against a set of profiles
        """
        kwargs = {
            'profile__id': 14879,
            'profile__romanized_first_name': 'Jane',
            'profile__romanized_last_name': 'Smith',
            'profile__user__email': '*****@*****.**',
            'profile__address': '1 Main St, Room B345',
            'profile__city': 'Boston',
            'profile__state_or_territory': 'US-MA',
            'profile__country': 'US',
            'profile__postal_code': '02115',
            'profile__phone_number': '+1 617 293-3423',
        }

        with mute_signals(post_save):
            exam_profiles = [ExamProfileFactory.create(**kwargs)]
            exam_profiles[0].updated_on = FIXED_DATETIME

        self.cdd_writer.write(self.tsv_file, exam_profiles)

        assert self.tsv_rows[0] == (
            "14879\tJane\tSmith\[email protected]\t"
            "1 Main St, Room B345\t\t\t"  # triple tab is for blank address2 and address3
            "Boston\tMA\t02115\tUSA\t"
            "6172933423\t1\t2016/05/15 15:02:55")
Exemple #8
0
    def test_write_cdd_file(self):
        """
        Tests cdd_writer against a set of profiles
        """
        kwargs = {
            'profile__id': 14879,
            'profile__romanized_first_name': 'Jane',
            'profile__romanized_last_name': 'Smith',
            'profile__user__email': '*****@*****.**',
            'profile__address': '1 Main St, Room B345',
            'profile__city': 'Boston',
            'profile__state_or_territory': 'US-MA',
            'profile__country': 'US',
            'profile__postal_code': '02115',
            'profile__phone_number': '+1 617 293-3423',
        }

        with mute_signals(post_save):
            exam_profiles = [ExamProfileFactory.create(**kwargs)]
            exam_profiles[0].updated_on = FIXED_DATETIME

        self.cdd_writer.write(self.tsv_file, exam_profiles)

        assert self.tsv_rows[0] == (
            "14879\tJane\tSmith\[email protected]\t"
            "1 Main St, Room B345\t\t\t"  # triple tab is for blank address2 and address3
            "Boston\tMA\t02115\tUSA\t"
            "6172933423\t1\t2016/05/15 15:02:55"
        )
Exemple #9
0
    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
Exemple #10
0
    def test_get_pearson_exam_status_eligible(self):
        """
        test get_pearson_exam_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_pearson_exam_status() == ExamProfile.PROFILE_SCHEDULABLE

        # not eligible
        for now_value in invalid_dates:
            mmtrack.now = now_value
            assert mmtrack.get_pearson_exam_status() == ExamProfile.PROFILE_SUCCESS
 def test_profile_country_to_alpha3_invalid_country(self):
     """
     A profile with an invalid country code should raise an InvalidProfileDataException
     """
     with mute_signals(post_save):
         profile = ExamProfileFactory(profile__country='XXXX')
     with self.assertRaises(InvalidProfileDataException):
         CDDWriter.profile_country_to_alpha3(profile)
 def test_profile_phone_number_exceptions(self, bad_number):
     """
     It should raise exceptions for bad data
     """
     with mute_signals(post_save):
         profile = ExamProfileFactory(profile__phone_number=bad_number)
     with self.assertRaises(InvalidProfileDataException):
         CDDWriter.profile_phone_number_to_raw_number(profile)
     with self.assertRaises(InvalidProfileDataException):
         CDDWriter.profile_phone_number_to_country_code(profile)
 def test_last_name(self, unromanized, romanized, expected):
     """
     Test that the `last_name` method prefers the `romanized_last_name`
     field, and falls back on `last_name` field.
     """
     with mute_signals(post_save):
         profile = ExamProfileFactory(
             profile__last_name=unromanized,
             profile__romanized_last_name=romanized,
         )
     assert CDDWriter.last_name(profile) == expected
 def test_profile_phone_number_functions(self, input_number,
                                         expected_country_code,
                                         expected_number):
     """
     A profile with a valid phone number should be parsed correctly
     """
     with mute_signals(post_save):
         profile = ExamProfileFactory(profile__phone_number=input_number)
     assert CDDWriter.profile_phone_number_to_raw_number(
         profile) == expected_number
     assert CDDWriter.profile_phone_number_to_country_code(
         profile) == expected_country_code
    def setUpTestData(cls):
        sftp = Mock()
        cls.now = now_in_utc()
        cls.processor = download.ArchivedResponseProcessor(sftp)
        with mute_signals(post_save):
            cls.success_profiles = ExamProfileFactory.create_batch(2) + [
                ExamProfileFactory.create(
                    profile__id=999,
                    profile__student_id=1000),  # disjoint id and student_id
            ]
            cls.failure_profiles = ExamProfileFactory.create_batch(2)

        cls.success_results = ([
            VCDCResult(
                client_candidate_id=exam_profile.profile.student_id,
                status=VCDC_SUCCESS_STATUS,
                date=cls.now,
                message='',
            ) for exam_profile in cls.success_profiles
        ], [])
        cls.failed_results = ([
            VCDCResult(
                client_candidate_id=cls.failure_profiles[0].profile.student_id,
                status=VCDC_FAILURE_STATUS,
                date=cls.now,
                message='',
            ),
            VCDCResult(
                client_candidate_id=cls.failure_profiles[1].profile.student_id,
                status=VCDC_FAILURE_STATUS,
                date=cls.now,
                message='Bad address',
            ),
        ], [])

        cls.all_results = (
            cls.success_results[0] + cls.failed_results[0],
            cls.success_results[1] + cls.failed_results[1],
        )
Exemple #16
0
    def setUpTestData(cls):
        sftp = Mock()
        cls.now = now_in_utc()
        cls.processor = download.ArchivedResponseProcessor(sftp)
        with mute_signals(post_save):
            cls.success_profiles = ExamProfileFactory.create_batch(2) + [
                ExamProfileFactory.create(profile__id=999, profile__student_id=1000),  # disjoint id and student_id
            ]
            cls.failure_profiles = ExamProfileFactory.create_batch(2)

        cls.success_results = ([
            VCDCResult(
                client_candidate_id=exam_profile.profile.student_id,
                status=VCDC_SUCCESS_STATUS,
                date=cls.now,
                message='',
            ) for exam_profile in cls.success_profiles
        ], [])
        cls.failed_results = ([
            VCDCResult(
                client_candidate_id=cls.failure_profiles[0].profile.student_id,
                status=VCDC_FAILURE_STATUS,
                date=cls.now,
                message='',
            ),
            VCDCResult(
                client_candidate_id=cls.failure_profiles[1].profile.student_id,
                status=VCDC_FAILURE_STATUS,
                date=cls.now,
                message='Bad address',
            ),
        ], [])

        cls.all_results = (
            cls.success_results[0] + cls.failed_results[0],
            cls.success_results[1] + cls.failed_results[1],
        )
Exemple #17
0
    def test_write_cdd_file_with_blank_romanized_name(self):
        """
        Tests cdd_writer against a profile without romanized name fields
        """
        kwargs = {
            'profile__id': 9876,
            'profile__first_name': 'Jane',
            'profile__last_name': 'Smith',
            'profile__romanized_first_name': None,
            'profile__romanized_last_name': None,
            'profile__phone_number': '+1 617 293-3423',
        }

        with mute_signals(post_save):
            exam_profiles = [ExamProfileFactory.create(**kwargs)]
            exam_profiles[0].profile.updated_on = FIXED_DATETIME
        self.cdd_writer.write(self.tsv_file, exam_profiles)

        assert self.tsv_rows[0].startswith("9876\tJane\tSmith\t")
    def test_write_cdd_file_with_blank_romanized_name(self):
        """
        Tests cdd_writer against a profile without romanized name fields
        """
        kwargs = {
            'profile__id': 9876,
            'profile__first_name': 'Jane',
            'profile__last_name': 'Smith',
            'profile__romanized_first_name': None,
            'profile__romanized_last_name': None,
            'profile__phone_number': '+1 617 293-3423',
        }

        with mute_signals(post_save):
            exam_profiles = [ExamProfileFactory.create(**kwargs)]
            exam_profiles[0].profile.updated_on = FIXED_DATETIME
        self.cdd_writer.write(self.tsv_file, exam_profiles)

        assert self.tsv_rows[0].startswith("9876\tJane\tSmith\t")
Exemple #19
0
    def create_exams(self, current, edx_passed, exam_passed, new_offering, can_schedule, future_exam, need_to_pay):
        """Create an exam and mark it and the related course as passed or not passed"""
        # pylint: disable-msg=too-many-arguments
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        course = Course.objects.get(title='Digital Learning 200')
        if current:
            course_run = CourseRunFactory(course=course)
            call_command(
                "alter_data", 'set_to_enrolled', '--username', 'staff',
                '--course-run-key', course_run.edx_course_key
            )
            FinalGradeFactory.create(
                user=self.user, course_run=course_run, grade=0.8 if edx_passed else 0.2, passed=True
            )
        else:
            if edx_passed:
                call_command(
                    "alter_data", 'set_to_passed', '--username', 'staff',
                    '--course-title', 'Digital Learning 200', '--grade', '75',
                )
            else:
                call_command(
                    "alter_data", 'set_to_failed', '--username', 'staff',
                    '--course-title', 'Digital Learning 200', '--grade', '45',
                )
            course_run = course.courserun_set.first()

        ExamProfileFactory.create(status='success', profile=self.user.profile)
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True
        )
        LineFactory.create(
            order__status=Order.FULFILLED,
            course_key=course_run
        )

        ProctoredExamGradeFactory.create(
            user=self.user,
            course=course,
            exam_run=exam_run,
            passed=exam_passed,
            percentage_grade=0.8 if exam_passed else 0.3
        )
        if new_offering:
            CourseRunFactory.create(course=course)

        if can_schedule:
            exam_run = ExamRunFactory.create(
                scheduling_past=False,
                scheduling_future=False,
                authorized=True,
                course=course
            )
            ExamAuthorizationFactory.create(
                user=self.user, course=course, exam_run=exam_run, status='success',
            )

        if future_exam:
            ExamRunFactory.create(
                scheduling_past=False,
                scheduling_future=True,
                authorized=True,
                course=course
            )
        if need_to_pay:
            exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
            ExamAuthorizationFactory.create(
                user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True
            )
            ProctoredExamGradeFactory.create(
                user=self.user,
                course=course,
                exam_run=exam_run,
                passed=False,
                percentage_grade=0.3
            )
 def test_profile_state(self, country, state, expected):
     """Test that profile_state returns expected values"""
     with mute_signals(post_save):
         profile = ExamProfileFactory(profile__country=country,
                                      profile__state_or_territory=state)
     assert CDDWriter.profile_state(profile) == expected