Пример #1
0
    def test_list_with_certificate_type(self):
        """ Verify the list endpoint supports filtering by certificate_type."""
        course_cert = factories.CourseCertificateFactory(
            certificate_type="verified")
        factories.UserCredentialFactory.create(credential=course_cert)

        # course_id is mandatory
        response = self.client.get(self.list_path,
                                   data={
                                       'course_id':
                                       self.course_id,
                                       'certificate_type':
                                       self.course_certificate.certificate_type
                                   })

        # after filtering it is only one related record
        expected = UserCredentialSerializer(self.user_credential,
                                            context={
                                                'request': self.request
                                            }).data
        self.assertEqual(json.loads(response.content), {
            'count': 1,
            'next': None,
            'previous': None,
            'results': [expected]
        })
Пример #2
0
    def setUp(self):
        super(CourseCredentialViewSetTests, self).setUp()

        self.course_certificate = factories.CourseCertificateFactory()
        self.course_id = self.course_certificate.course_id
        self.user_credential = factories.UserCredentialFactory.create(
            credential=self.course_certificate)
Пример #3
0
 def test_invalid_credential(self):
     """ Verify the view returns 404 for attempts to render unsupported credentials. """
     self.user_credential = factories.UserCredentialFactory(credential=factories.CourseCertificateFactory())
     response = self.client.get(self.user_credential.get_absolute_url())
     self.assertEqual(response.status_code, 404)
Пример #4
0
 def test_list_with_course_id(self):
     """ Verify the list endpoint supports filter data by course_id."""
     course_cert = factories.CourseCertificateFactory(course_id="fake-id")
     factories.UserCredentialFactory.create(credential=course_cert)
     self.assert_list_with_id_filter(data={'course_id': self.course_id})