def test_no_signatories_404(client): """Test that a 404 is returned for a request for a certificate that has no signatories set for the course""" certificate = MicromastersCourseCertificateFactory.create() assert client.get(certificate_url(certificate.hash)).status_code == status.HTTP_404_NOT_FOUND certificate = MicromastersProgramCertificateFactory.create() assert client.get(program_certificate_url(certificate.hash)).status_code == status.HTTP_404_NOT_FOUND
def test_no_signatories_404(client): """Test that a 404 is returned for a request for a certificate that has no signatories set for the course""" certificate = MicromastersCourseCertificateFactory.create() assert client.get(certificate_url( certificate.hash)).status_code == status.HTTP_404_NOT_FOUND certificate = MicromastersProgramCertificateFactory.create() assert client.get(program_certificate_url( certificate.hash)).status_code == status.HTTP_404_NOT_FOUND
def test_create_course_certificate(self, generate_program_cert_mock, mock_on_commit): """ Test that generate_program_certificate is called when a course certificate is created """ course = CourseFactory.create() cert = MicromastersCourseCertificateFactory.create(user=self.user, course=course) generate_program_cert_mock.assert_called_once_with(self.user, course.program) cert.save() generate_program_cert_mock.assert_called_once_with(self.user, course.program)
def create_passed_enrolled_again(self): """Make course passed and user retaking/auditing the course again""" self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED) course = Course.objects.get(title='Digital Learning 200') CourseCertificateSignatoriesFactory.create(course=course) call_command( "alter_data", 'set_past_run_to_passed', '--username', 'staff', '--course-title', 'Digital Learning 200', '--grade', '87', ) final_grade = FinalGrade.objects.filter( course_run__course__title='Digital Learning 200', user=self.user ).first() CourseRunGradingStatus.objects.create(course_run=final_grade.course_run, status='complete') MicromastersCourseCertificateFactory.create(user=self.user, course=course) course_run = CourseRunFactory.create(course=course) set_course_run_current(course_run, upgradeable=True, save=True) CachedEnrollmentHandler(self.user).set_or_create(course_run, verified=False)
def test_create_course_certificate(self, generate_program_cert_mock, mock_on_commit): """ Test that generate_program_certificate is called when a course certificate is created """ course = CourseFactory.create() cert = MicromastersCourseCertificateFactory.create(user=self.user, course=course) generate_program_cert_mock.assert_called_once_with( self.user, course.program) cert.save() generate_program_cert_mock.assert_called_once_with( self.user, course.program)
def test_valid_certificate_200(client): """Test that a request for a valid certificate with signatories results in a 200""" certificate = MicromastersCourseCertificateFactory.create() signatory = CourseCertificateSignatoriesFactory.create(course=certificate.course) resp = client.get(certificate_url(certificate.hash)) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'certificate_hash': certificate.hash, 'course_title': certificate.course.title, 'program_title': certificate.course.program.title, 'name': certificate.user.profile.full_name, 'signatories': [signatory], 'certificate': certificate }, resp.context_data ) assert reverse('certificate', args=[certificate.hash]) in resp.content.decode('utf-8')
def test_valid_certificate_200(client): """Test that a request for a valid certificate with signatories results in a 200""" certificate = MicromastersCourseCertificateFactory.create() signatory = CourseCertificateSignatoriesFactory.create( course=certificate.course) resp = client.get(certificate_url(certificate.hash)) assert resp.status_code == status.HTTP_200_OK assert is_subset_dict( { 'certificate_hash': certificate.hash, 'course_title': certificate.course.title, 'program_title': certificate.course.program.title, 'name': certificate.user.profile.full_name, 'signatories': [signatory], 'certificate': certificate }, resp.context_data) assert reverse('certificate', args=[certificate.hash]) in resp.content.decode('utf-8')