コード例 #1
0
    def test_has_passing_certificate_fa(self):
        """
        Assert that has_passing_certificate is true if user has a cert even if has_paid is false for FA programs
        """
        mmtrack = MMTrack(
            user=self.user,
            program=self.program_financial_aid,
            edx_user_data=self.cached_edx_user_data
        )
        key = self.crun_fa.edx_course_key
        assert mmtrack.has_passing_certificate(key) is False
        assert mmtrack.has_paid(key) is False

        cert_json = {
            "username": "******",
            "course_id": self.crun_fa.edx_course_key,
            "certificate_type": "verified",
            "status": "downloadable",
            "is_passing": True,
            "download_url": "http://www.example.com/demo.pdf",
            "grade": "0.98"
        }
        cached_edx_user_data = MagicMock(
            spec=CachedEdxUserData,
            enrollments=CachedEnrollment.deserialize_edx_data(self.enrollments_json),
            certificates=CachedCertificate.deserialize_edx_data(self.certificates_json + [cert_json]),
            current_grades=CachedCurrentGrade.deserialize_edx_data(self.current_grades_json),
        )
        mmtrack = MMTrack(
            user=self.user,
            program=self.program_financial_aid,
            edx_user_data=cached_edx_user_data
        )
        assert mmtrack.has_passing_certificate(key) is True
        assert mmtrack.has_paid(key) is False
コード例 #2
0
 def test_has_passing_certificate(self, certificate_type, is_passing, expected_result):
     """
     Test for has_passing_certificate method with different type of certificates
     """
     course_key = self.crun_fa.edx_course_key
     cert_json = {
         "username": "******",
         "course_id": course_key,
         "certificate_type": certificate_type,
         "is_passing": is_passing,
         "status": "downloadable",
         "download_url": "http://www.example.com/demo.pdf",
         "grade": "0.98"
     }
     cached_edx_user_data = MagicMock(
         spec=CachedEdxUserData,
         enrollments=CachedEnrollment.deserialize_edx_data(self.enrollments_json),
         certificates=CachedCertificate.deserialize_edx_data(self.certificates_json + [cert_json]),
         current_grades=CachedCurrentGrade.deserialize_edx_data(self.current_grades_json),
     )
     mmtrack = MMTrack(
         user=self.user,
         program=self.program_financial_aid,
         edx_user_data=cached_edx_user_data
     )
     assert mmtrack.has_passing_certificate(course_key) is expected_result
コード例 #3
0
ファイル: utils_test.py プロジェクト: mitodl/micromasters
    def test_has_passing_certificate_fa(self):
        """
        Assert that has_passing_certificate is true if user has a cert even if has_paid is false for FA programs
        """
        mmtrack = MMTrack(
            user=self.user,
            program=self.program_financial_aid,
            edx_user_data=self.cached_edx_user_data
        )
        key = self.crun_fa.edx_course_key
        assert mmtrack.has_passing_certificate(key) is False
        assert mmtrack.has_paid(key) is False

        cert_json = {
            "username": "******",
            "course_id": self.crun_fa.edx_course_key,
            "certificate_type": "verified",
            "status": "downloadable",
            "is_passing": True,
            "download_url": "http://www.example.com/demo.pdf",
            "grade": "0.98"
        }
        cached_edx_user_data = MagicMock(
            spec=CachedEdxUserData,
            enrollments=CachedEnrollment.deserialize_edx_data(self.enrollments_json),
            certificates=CachedCertificate.deserialize_edx_data(self.certificates_json + [cert_json]),
            current_grades=CachedCurrentGrade.deserialize_edx_data(self.current_grades_json),
        )
        mmtrack = MMTrack(
            user=self.user,
            program=self.program_financial_aid,
            edx_user_data=cached_edx_user_data
        )
        assert mmtrack.has_passing_certificate(key) is True
        assert mmtrack.has_paid(key) is False
コード例 #4
0
ファイル: utils_test.py プロジェクト: mitodl/micromasters
 def test_has_passing_certificate(self, certificate_type, is_passing, expected_result):
     """
     Test for has_passing_certificate method with different type of certificates
     """
     course_key = self.crun_fa.edx_course_key
     cert_json = {
         "username": "******",
         "course_id": course_key,
         "certificate_type": certificate_type,
         "is_passing": is_passing,
         "status": "downloadable",
         "download_url": "http://www.example.com/demo.pdf",
         "grade": "0.98"
     }
     cached_edx_user_data = MagicMock(
         spec=CachedEdxUserData,
         enrollments=CachedEnrollment.deserialize_edx_data(self.enrollments_json),
         certificates=CachedCertificate.deserialize_edx_data(self.certificates_json + [cert_json]),
         current_grades=CachedCurrentGrade.deserialize_edx_data(self.current_grades_json),
     )
     mmtrack = MMTrack(
         user=self.user,
         program=self.program_financial_aid,
         edx_user_data=cached_edx_user_data
     )
     assert mmtrack.has_passing_certificate(course_key) is expected_result
コード例 #5
0
    def setUpTestData(cls):
        super().setUpTestData()
        # create an user
        cls.user = UserFactory.create()
        cls.cached_edx_user_data = MagicMock(
            spec=CachedEdxUserData,
            enrollments=CachedEnrollment.deserialize_edx_data(cls.enrollments_json),
            certificates=CachedCertificate.deserialize_edx_data(cls.certificates_json),
            current_grades=CachedCurrentGrade.deserialize_edx_data(cls.current_grades_json),
        )

        # create the programs
        cls.program = ProgramFactory.create(live=True, financial_aid_availability=False, price=1000)
        cls.program_financial_aid = ProgramFactory.create(live=True, financial_aid_availability=True, price=1000)

        # create course runs for the normal program
        cls.course = CourseFactory.create(program=cls.program)
        expected_course_keys = [
            "course-v1:edX+DemoX+Demo_Course",
            "course-v1:MITx+8.MechCX+2014_T1",
            '',
            None,
            'course-v1:odl+FOO102+CR-FALL16'
        ]

        cls.cruns = []
        for course_key in expected_course_keys:
            course_run = CourseRunFactory.create(
                course=cls.course,
                edx_course_key=course_key
            )
            if course_key:
                cls.cruns.append(course_run)

        # and the program with financial aid
        finaid_course = CourseFactory.create(program=cls.program_financial_aid)
        cls.now = now_in_utc()
        cls.end_date = cls.now - timedelta(weeks=45)
        cls.crun_fa = CourseRunFactory.create(
            course=finaid_course,
            start_date=cls.now-timedelta(weeks=52),
            end_date=cls.end_date,
            enrollment_start=cls.now-timedelta(weeks=62),
            enrollment_end=cls.now-timedelta(weeks=53),
            edx_course_key="course-v1:odl+FOO101+CR-FALL15"
        )
        cls.crun_fa2 = CourseRunFactory.create(
            course=finaid_course
        )
        CourseRunFactory.create(
            course=finaid_course,
            edx_course_key=None
        )
コード例 #6
0
ファイル: utils_test.py プロジェクト: mitodl/micromasters
    def setUpTestData(cls):
        super().setUpTestData()
        # create an user
        cls.user = UserFactory.create()
        cls.cached_edx_user_data = MagicMock(
            spec=CachedEdxUserData,
            enrollments=CachedEnrollment.deserialize_edx_data(cls.enrollments_json),
            certificates=CachedCertificate.deserialize_edx_data(cls.certificates_json),
            current_grades=CachedCurrentGrade.deserialize_edx_data(cls.current_grades_json),
        )

        # create the programs
        cls.program = ProgramFactory.create(live=True, financial_aid_availability=False, price=1000)
        cls.program_financial_aid = ProgramFactory.create(live=True, financial_aid_availability=True, price=1000)

        # create course runs for the normal program
        cls.course = CourseFactory.create(program=cls.program)
        expected_course_keys = [
            "course-v1:edX+DemoX+Demo_Course",
            "course-v1:MITx+8.MechCX+2014_T1",
            '',
            None,
            'course-v1:odl+FOO102+CR-FALL16'
        ]

        cls.cruns = []
        for course_key in expected_course_keys:
            course_run = CourseRunFactory.create(
                course=cls.course,
                edx_course_key=course_key
            )
            if course_key:
                cls.cruns.append(course_run)

        # and the program with financial aid
        finaid_course = CourseFactory.create(program=cls.program_financial_aid)
        cls.now = now_in_utc()
        cls.end_date = cls.now - timedelta(weeks=45)
        cls.crun_fa = CourseRunFactory.create(
            course=finaid_course,
            start_date=cls.now-timedelta(weeks=52),
            end_date=cls.end_date,
            enrollment_start=cls.now-timedelta(weeks=62),
            enrollment_end=cls.now-timedelta(weeks=53),
            edx_course_key="course-v1:odl+FOO101+CR-FALL15"
        )
        cls.crun_fa2 = CourseRunFactory.create(
            course=finaid_course
        )
        CourseRunFactory.create(
            course=finaid_course,
            edx_course_key=None
        )