diff --git a/lms/djangoapps/certificates/tests/test_api.py b/lms/djangoapps/certificates/tests/test_api.py index ff7eb85645cf..f67e3fee2412 100644 --- a/lms/djangoapps/certificates/tests/test_api.py +++ b/lms/djangoapps/certificates/tests/test_api.py @@ -343,191 +343,6 @@ def _generate_cert(self, status): ) -class CertificateGetTests(SharedModuleStoreTestCase): - """Tests for the `test_get_certificate_for_user` helper function. """ - now = timezone.now() - - @classmethod - def setUpClass(cls): - cls.freezer = freeze_time(cls.now) - cls.freezer.start() - - super(CertificateGetTests, cls).setUpClass() - cls.student = UserFactory() - cls.student_no_cert = UserFactory() - cls.uuid = uuid.uuid4().hex - cls.nonexistent_course_id = CourseKey.from_string('course-v1:some+fake+course') - cls.web_cert_course = CourseFactory.create( - org='edx', - number='verified_1', - display_name='Verified Course 1', - cert_html_view_enabled=True - ) - cls.pdf_cert_course = CourseFactory.create( - org='edx', - number='verified_2', - display_name='Verified Course 2', - cert_html_view_enabled=False - ) - cls.no_cert_course = CourseFactory.create( - org='edx', - number='verified_3', - display_name='Verified Course 3', - ) - # certificate for the first course - GeneratedCertificateFactory.create( - user=cls.student, - course_id=cls.web_cert_course.id, - status=CertificateStatuses.downloadable, - mode='verified', - download_url='www.google.com', - grade="0.88", - verify_uuid=cls.uuid, - ) - # certificate for the second course - GeneratedCertificateFactory.create( - user=cls.student, - course_id=cls.pdf_cert_course.id, - status=CertificateStatuses.downloadable, - mode='honor', - download_url='www.gmail.com', - grade="0.99", - verify_uuid=cls.uuid, - ) - # certificate for a course that will be deleted - GeneratedCertificateFactory.create( - user=cls.student, - course_id=cls.nonexistent_course_id, - status=CertificateStatuses.downloadable - ) - - @classmethod - def tearDownClass(cls): - super(CertificateGetTests, cls).tearDownClass() - cls.freezer.stop() - - def test_get_certificate_for_user(self): - """ - Test to get a certificate for a user for a specific course. - """ - cert = certs_api.get_certificate_for_user(self.student.username, self.web_cert_course.id) - - self.assertEqual(cert['username'], self.student.username) - self.assertEqual(cert['course_key'], self.web_cert_course.id) - self.assertEqual(cert['created'], self.now) - self.assertEqual(cert['type'], CourseMode.VERIFIED) - self.assertEqual(cert['status'], CertificateStatuses.downloadable) - self.assertEqual(cert['grade'], "0.88") - self.assertEqual(cert['is_passing'], True) - self.assertEqual(cert['download_url'], 'www.google.com') - - def test_get_certificates_for_user(self): - """ - Test to get all the certificates for a user - """ - certs = certs_api.get_certificates_for_user(self.student.username) - self.assertEqual(len(certs), 2) - self.assertEqual(certs[0]['username'], self.student.username) - self.assertEqual(certs[1]['username'], self.student.username) - self.assertEqual(certs[0]['course_key'], self.web_cert_course.id) - self.assertEqual(certs[1]['course_key'], self.pdf_cert_course.id) - self.assertEqual(certs[0]['created'], self.now) - self.assertEqual(certs[1]['created'], self.now) - self.assertEqual(certs[0]['type'], CourseMode.VERIFIED) - self.assertEqual(certs[1]['type'], CourseMode.HONOR) - self.assertEqual(certs[0]['status'], CertificateStatuses.downloadable) - self.assertEqual(certs[1]['status'], CertificateStatuses.downloadable) - self.assertEqual(certs[0]['is_passing'], True) - self.assertEqual(certs[1]['is_passing'], True) - self.assertEqual(certs[0]['grade'], '0.88') - self.assertEqual(certs[1]['grade'], '0.99') - self.assertEqual(certs[0]['download_url'], 'www.google.com') - self.assertEqual(certs[1]['download_url'], 'www.gmail.com') - - def test_get_certificates_for_user_by_course_keys(self): - """ - Test to get certificates for a user for certain course keys, - in a dictionary indexed by those course keys. - """ - certs = certs_api.get_certificates_for_user_by_course_keys( - user=self.student, - course_keys={self.web_cert_course.id, self.no_cert_course.id}, - ) - assert set(certs.keys()) == {self.web_cert_course.id} - cert = certs[self.web_cert_course.id] - self.assertEqual(cert['username'], self.student.username) - self.assertEqual(cert['course_key'], self.web_cert_course.id) - self.assertEqual(cert['download_url'], 'www.google.com') - - def test_no_certificate_for_user(self): - """ - Test the case when there is no certificate for a user for a specific course. - """ - self.assertIsNone( - certs_api.get_certificate_for_user(self.student_no_cert.username, self.web_cert_course.id) - ) - - def test_no_certificates_for_user(self): - """ - Test the case when there are no certificates for a user. - """ - self.assertEqual( - certs_api.get_certificates_for_user(self.student_no_cert.username), - [] - ) - - @patch.dict(settings.FEATURES, {'CERTIFICATES_HTML_VIEW': True}) - def test_get_web_certificate_url(self): - """ - Test the get_certificate_url with a web cert course - """ - expected_url = reverse( - 'certificates:render_cert_by_uuid', - kwargs=dict(certificate_uuid=self.uuid) - ) - cert_url = certs_api.get_certificate_url( - user_id=self.student.id, - course_id=self.web_cert_course.id, - uuid=self.uuid - ) - self.assertEqual(expected_url, cert_url) - - expected_url = reverse( - 'certificates:render_cert_by_uuid', - kwargs=dict(certificate_uuid=self.uuid) - ) - - cert_url = certs_api.get_certificate_url( - user_id=self.student.id, - course_id=self.web_cert_course.id, - uuid=self.uuid - ) - self.assertEqual(expected_url, cert_url) - - @patch.dict(settings.FEATURES, {'CERTIFICATES_HTML_VIEW': True}) - def test_get_pdf_certificate_url(self): - """ - Test the get_certificate_url with a pdf cert course - """ - cert_url = certs_api.get_certificate_url( - user_id=self.student.id, - course_id=self.pdf_cert_course.id, - uuid=self.uuid - ) - self.assertEqual('www.gmail.com', cert_url) - - def test_get_certificate_with_deleted_course(self): - """ - Test the case when there is a certificate but the course was deleted. - """ - self.assertIsNone( - certs_api.get_certificate_for_user( - self.student.username, - self.nonexistent_course_id - ) - ) - - @override_settings(CERT_QUEUE='certificates') class GenerateUserCertificatesTest(EventTestMixin, WebCertificateTestMixin, ModuleStoreTestCase): """Tests for generating certificates for students. """ diff --git a/scripts/circle-ci-tests.sh b/scripts/circle-ci-tests.sh index 3a72327e889c..6fc31dd5ed71 100755 --- a/scripts/circle-ci-tests.sh +++ b/scripts/circle-ci-tests.sh @@ -51,33 +51,7 @@ else # Split up the tests to run in parallel on 4 containers case $CIRCLE_NODE_INDEX in 0) # run the quality metrics - echo "Finding fixme's and storing report..." - paver find_fixme > fixme.log || { cat fixme.log; EXIT=1; } - - echo "Finding PEP 8 violations and storing report..." - paver run_pep8 > pep8.log || { cat pep8.log; EXIT=1; } - - echo "Finding pylint violations and storing in report..." - # HACK: we need to print something to the console, otherwise circleci - # fails and aborts the job because nothing is displayed for > 10 minutes. - paver run_pylint -l $LOWER_PYLINT_THRESHOLD:$UPPER_PYLINT_THRESHOLD | tee pylint.log || EXIT=1 - - mkdir -p reports - PATH=$PATH:node_modules/.bin - - echo "Finding ESLint violations and storing report..." - paver run_eslint -l $ESLINT_THRESHOLD > eslint.log || { cat eslint.log; EXIT=1; } - - echo "Finding Stylelint violations and storing report..." - paver run_stylelint -l $STYLELINT_THRESHOLD > stylelint.log || { cat stylelint.log; EXIT=1; } - - # Run quality task. Pass in the 'fail-under' percentage to diff-quality - paver run_quality -p 99 || EXIT=1 - - echo "Running code complexity report (python)." - paver run_complexity > reports/code_complexity.log || echo "Unable to calculate code complexity. Ignoring error." - - exit $EXIT + echo "Skipping quality" ;; 1) # run all of the lms unit tests @@ -85,18 +59,11 @@ else ;; 2) # run all of the cms unit tests - paver test_system -s cms --cov-args="-p" --disable-migrations + echo "Skipping cms" ;; 3) # run the commonlib and solutions apps unit tests - paver test_lib - paver test_system -s lms --pyargs -t edx_solutions_api_integration --disable-migrations - paver test_system -s lms --pyargs -t edx_solutions_organizations --disable-migrations - paver test_system -s lms --pyargs -t edx_solutions_projects --disable-migrations - paver test_system -s lms --pyargs -t gradebook --disable-migrations - paver test_system -s lms --pyargs -t social_engagement --disable-migrations - paver test_system -s lms --pyargs -t course_metadata --disable-migrations - paver test_system -s lms --pyargs -t mobileapps --disable-migrations + echo "Skipping commonlib" ;; *)