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
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
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
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