예제 #1
0
 def test_method_with_invalidated_cert(self, status):
     """ Verify that if certificate is marked as invalid than method will return
     True. """
     generated_cert = self._generate_cert(status)
     self._invalidate_certificate(generated_cert, True)
     self.assertTrue(
         certs_api.is_certificate_invalid(self.student, self.course.id))
예제 #2
0
 def test_method_with_inactive_invalidated_cert(self, status):
     """ Verify that if certificate is valid but it's invalidated status is
     false than method will return false. """
     generated_cert = self._generate_cert(status)
     self._invalidate_certificate(generated_cert, False)
     self.assertFalse(
         certs_api.is_certificate_invalid(self.student, self.course.id))
예제 #3
0
 def test_method_with_inactive_invalidated_cert(self, status):
     """ Verify that if certificate is valid but it's invalidated status is
     false than method will return false. """
     generated_cert = self._generate_cert(status)
     self._invalidate_certificate(generated_cert, False)
     self.assertFalse(
         certs_api.is_certificate_invalid(self.student, self.course.id)
     )
예제 #4
0
 def test_method_with_invalidated_cert(self, status):
     """ Verify that if certificate is marked as invalid than method will return
     True. """
     generated_cert = self._generate_cert(status)
     self._invalidate_certificate(generated_cert, True)
     self.assertTrue(
         certs_api.is_certificate_invalid(self.student, self.course.id)
     )
예제 #5
0
 def test_method_with_no_certificate(self):
     """ Test the case when there is no certificate for a user for a specific course. """
     course = CourseFactory.create(org='edx',
                                   number='honor',
                                   display_name='Course 1')
     # Also check query count for 'is_certificate_invalid' method.
     with self.assertNumQueries(1):
         self.assertFalse(
             certs_api.is_certificate_invalid(self.student, course.id))
예제 #6
0
 def test_method_with_no_certificate(self):
     """ Test the case when there is no certificate for a user for a specific course. """
     course = CourseFactory.create(
         org='edx',
         number='honor',
         display_name='Course 1'
     )
     # Also check query count for 'is_certificate_invalid' method.
     with self.assertNumQueries(1):
         self.assertFalse(
             certs_api.is_certificate_invalid(self.student, course.id)
         )
예제 #7
0
    def test_method_with_all_statues(self, status):
        """ Verify method return True if certificate has valid status but it is
        marked as invalid in CertificateInvalidation table. """

        certificate = self._generate_cert(status)
        CertificateInvalidationFactory.create(
            generated_certificate=certificate,
            invalidated_by=self.global_staff,
            active=True)
        # Also check query count for 'is_certificate_invalid' method.
        with self.assertNumQueries(2):
            self.assertTrue(
                certs_api.is_certificate_invalid(self.student, self.course.id))
예제 #8
0
    def test_method_with_all_statues(self, status):
        """ Verify method return True if certificate has valid status but it is
        marked as invalid in CertificateInvalidation table. """

        certificate = self._generate_cert(status)
        CertificateInvalidationFactory.create(
            generated_certificate=certificate,
            invalidated_by=self.global_staff,
            active=True
        )
        # Also check query count for 'is_certificate_invalid' method.
        with self.assertNumQueries(2):
            self.assertTrue(
                certs_api.is_certificate_invalid(self.student, self.course.id)
            )