diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index c8fecf9de9..4c2a410594 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -302,6 +302,12 @@ class GeneratedCertificate(models.Model): else: return query.values('status').annotate(count=Count('status')) + def __repr__(self): + return "".format( + course_id=self.course_id, + user=self.user + ) + def invalidate(self): """ Invalidate Generated Certificate by marking it 'unavailable'. diff --git a/lms/djangoapps/certificates/tests/test_api.py b/lms/djangoapps/certificates/tests/test_api.py index c0291a14db..e5f0d145f7 100644 --- a/lms/djangoapps/certificates/tests/test_api.py +++ b/lms/djangoapps/certificates/tests/test_api.py @@ -369,6 +369,7 @@ class CertificateGetTests(SharedModuleStoreTestCase): @classmethod def tearDownClass(cls): + super(CertificateGetTests, cls).tearDownClass() cls.freezer.stop() def test_get_certificate_for_user(self): diff --git a/lms/djangoapps/certificates/tests/test_webview_views.py b/lms/djangoapps/certificates/tests/test_webview_views.py index 85e9c9ebfa..738d57386d 100644 --- a/lms/djangoapps/certificates/tests/test_webview_views.py +++ b/lms/djangoapps/certificates/tests/test_webview_views.py @@ -721,7 +721,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase): course_id=unicode(self.course.id) ) self.cert.delete() - self.assertEqual(len(GeneratedCertificate.eligible_certificates.all()), 0) + self.assertListEqual(list(GeneratedCertificate.eligible_certificates.all()), []) response = self.client.get(test_url) self.assertIn('invalid', response.content) @@ -744,7 +744,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase): preview mode. Either the certificate is marked active or not. """ self.cert.delete() - self.assertEqual(len(GeneratedCertificate.eligible_certificates.all()), 0) + self.assertListEqual(list(GeneratedCertificate.eligible_certificates.all()), []) self._add_course_certificates(count=1, signatory_count=2) test_url = get_certificate_url( user_id=self.user.id,