Quiet quality

This commit is contained in:
Nimisha Asthagiri
2018-01-18 16:26:58 -05:00
parent 75c3e865a4
commit dd20106c8b
7 changed files with 65 additions and 32 deletions

View File

@@ -108,7 +108,7 @@ class CertificatesRestApiTest(SharedModuleStoreTestCase, APITestCase):
resp = self.client.get(self.get_url(self.student.username))
# gets 404 instead of 403 for security reasons
self.assertEqual(resp.status_code, status.HTTP_404_NOT_FOUND)
self.assertEqual(resp.data, {u'detail': u'Not found.'}) # pylint: disable=no-member
self.assertEqual(resp.data, {u'detail': u'Not found.'})
self.client.logout()
# same student of the certificate
@@ -165,9 +165,9 @@ class CertificatesRestApiTest(SharedModuleStoreTestCase, APITestCase):
self.client.login(username=self.student_no_cert.username, password=USER_PASSWORD)
resp = self.client.get(self.get_url(self.student_no_cert.username))
self.assertEqual(resp.status_code, status.HTTP_404_NOT_FOUND)
self.assertIn('error_code', resp.data) # pylint: disable=no-member
self.assertIn('error_code', resp.data)
self.assertEqual(
resp.data['error_code'], # pylint: disable=no-member
resp.data['error_code'],
'no_certificate_for_user'
)
@@ -179,7 +179,7 @@ class CertificatesRestApiTest(SharedModuleStoreTestCase, APITestCase):
resp = self.client.get(self.get_url(self.student.username))
self.assertEqual(resp.status_code, status.HTTP_200_OK)
self.assertEqual(
resp.data, # pylint: disable=no-member
resp.data,
{
'username': self.student.username,
'status': CertificateStatuses.downloadable,

View File

@@ -308,7 +308,7 @@ class XQueueCertInterface(object):
mode_is_verified
)
cert, created = GeneratedCertificate.objects.get_or_create(user=student, course_id=course_id) # pylint: disable=no-member
cert, created = GeneratedCertificate.objects.get_or_create(user=student, course_id=course_id)
cert.mode = cert_mode
cert.user = student

View File

@@ -199,7 +199,7 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
'is_generating': False,
'is_unverified': False,
'download_url': '/certificates/user/{user_id}/course/{course_id}'.format(
user_id=self.student.id, # pylint: disable=no-member
user_id=self.student.id,
course_id=self.course.id,
),
'uuid': cert_status['uuid']
@@ -462,7 +462,7 @@ class CertificateGetTests(SharedModuleStoreTestCase):
kwargs=dict(certificate_uuid=self.uuid)
)
cert_url = certs_api.get_certificate_url(
user_id=self.student.id, # pylint: disable=no-member
user_id=self.student.id,
course_id=self.web_cert_course.id,
uuid=self.uuid
)
@@ -471,13 +471,13 @@ class CertificateGetTests(SharedModuleStoreTestCase):
expected_url = reverse(
'certificates:html_view',
kwargs={
"user_id": str(self.student.id), # pylint: disable=no-member
"user_id": str(self.student.id),
"course_id": unicode(self.web_cert_course.id),
}
)
cert_url = certs_api.get_certificate_url(
user_id=self.student.id, # pylint: disable=no-member
user_id=self.student.id,
course_id=self.web_cert_course.id
)
self.assertEqual(expected_url, cert_url)
@@ -488,7 +488,7 @@ class CertificateGetTests(SharedModuleStoreTestCase):
Test the get_certificate_url with a pdf cert course
"""
cert_url = certs_api.get_certificate_url(
user_id=self.student.id, # pylint: disable=no-member
user_id=self.student.id,
course_id=self.pdf_cert_course.id,
uuid=self.uuid
)

View File

@@ -216,12 +216,12 @@ class EligibleCertificateManagerTest(SharedModuleStoreTestCase):
self.eligible_cert = GeneratedCertificateFactory.create(
status=CertificateStatuses.downloadable,
user=self.user,
course_id=self.courses[0].id # pylint: disable=no-member
course_id=self.courses[0].id
)
self.ineligible_cert = GeneratedCertificateFactory.create(
status=CertificateStatuses.audit_passing,
user=self.user,
course_id=self.courses[1].id # pylint: disable=no-member
course_id=self.courses[1].id
)
def test_filter_ineligible_certificates(self):
@@ -232,7 +232,7 @@ class EligibleCertificateManagerTest(SharedModuleStoreTestCase):
"""
self.assertEqual(list(GeneratedCertificate.eligible_certificates.filter(user=self.user)), [self.eligible_cert])
self.assertEqual(
list(GeneratedCertificate.objects.filter(user=self.user)), # pylint: disable=no-member
list(GeneratedCertificate.objects.filter(user=self.user)),
[self.eligible_cert, self.ineligible_cert]
)
@@ -313,7 +313,7 @@ class CertificateInvalidationTest(SharedModuleStoreTestCase):
super(CertificateInvalidationTest, self).setUp()
self.course = CourseFactory()
self.user = UserFactory()
self.course_id = self.course.id # pylint: disable=no-member
self.course_id = self.course.id
self.certificate = GeneratedCertificateFactory.create(
status=CertificateStatuses.downloadable,
user=self.user,

View File

@@ -171,7 +171,7 @@ class XQueueCertInterfaceAddCertificateTest(ModuleStoreTestCase):
# Ensure the certificate was not generated
self.assertFalse(mock_send.called)
certificate = GeneratedCertificate.objects.get( # pylint: disable=no-member
certificate = GeneratedCertificate.objects.get(
user=self.user_2,
course_id=self.course.id
)
@@ -274,7 +274,7 @@ class XQueueCertInterfaceAddCertificateTest(ModuleStoreTestCase):
self.xqueue.add_cert(self.user_2, self.course.id)
self.assertEqual(
GeneratedCertificate.objects.get(user=self.user_2, course_id=self.course.id).status, # pylint: disable=no-member
GeneratedCertificate.objects.get(user=self.user_2, course_id=self.course.id).status,
expected_status
)

View File

@@ -113,7 +113,7 @@ class CertificateSearchTests(CertificateSupportTestCase):
]
self.course.certificates = {'certificates': certificates}
self.course.save() # pylint: disable=no-member
self.course.save()
self.store.update_item(self.course, self.user.id)
@ddt.data(
@@ -165,7 +165,7 @@ class CertificateSearchTests(CertificateSupportTestCase):
Test that email address that contains '+' accepted by student support
"""
self.student.email = "student+student@example.com"
self.student.save() # pylint: disable=no-member
self.student.save()
response = self._search(self.student.email)
self.assertEqual(response.status_code, 200)
@@ -194,7 +194,7 @@ class CertificateSearchTests(CertificateSupportTestCase):
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
def test_download_link(self):
self.cert.course_id = self.course.id # pylint: disable=no-member
self.cert.course_id = self.course.id
self.cert.download_url = ''
self.cert.save()
@@ -209,7 +209,7 @@ class CertificateSearchTests(CertificateSupportTestCase):
retrieved_cert["download_url"],
reverse(
'certificates:html_view',
kwargs={"user_id": self.student.id, "course_id": self.course.id} # pylint: disable=no-member
kwargs={"user_id": self.student.id, "course_id": self.course.id}
)
)
@@ -267,7 +267,7 @@ class CertificateRegenerateTests(CertificateSupportTestCase):
def test_regenerate_certificate(self):
response = self._regenerate(
course_key=self.course.id, # pylint: disable=no-member
course_key=self.course.id,
username=self.STUDENT_USERNAME,
)
self.assertEqual(response.status_code, 200)
@@ -397,7 +397,7 @@ class CertificateRegenerateTests(CertificateSupportTestCase):
def assertGeneratedCertExists(self, user, status):
""" Dry method to check if certificate exists. """
self.assertTrue(
GeneratedCertificate.objects.filter( # pylint: disable=no-member
GeneratedCertificate.objects.filter(
user=user, status=status
).exists()
)
@@ -449,7 +449,7 @@ class CertificateGenerateTests(CertificateSupportTestCase):
def test_generate_certificate(self):
response = self._generate(
course_key=self.course.id, # pylint: disable=no-member
course_key=self.course.id,
username=self.STUDENT_USERNAME,
)
self.assertEqual(response.status_code, 200)

View File

@@ -994,8 +994,12 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
"""
mock_get_course_run_details.return_value = self.mock_course_run_details
self._add_course_certificates(count=1, signatory_count=2)
self._create_custom_named_template('test_template_1_course', org_id=1, mode='honor', course_key=unicode(self.course.id))
self._create_custom_named_template('test_template_2_course', org_id=1, mode='verified', course_key=unicode(self.course.id))
self._create_custom_named_template(
'test_template_1_course', org_id=1, mode='honor', course_key=unicode(self.course.id),
)
self._create_custom_named_template(
'test_template_2_course', org_id=1, mode='verified', course_key=unicode(self.course.id),
)
self._create_custom_named_template('test_template_3_course', org_id=2, mode='honor')
test_url = get_certificate_url(
user_id=self.user.id,
@@ -1102,7 +1106,11 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
@override_settings(LANGUAGE_CODE='fr')
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
def test_certificate_custom_language_template_with_org_mode_and_course_key(self, mock_get_org_id, mock_get_course_run_details):
def test_certificate_custom_language_template_with_org_mode_and_course_key(
self,
mock_get_org_id,
mock_get_course_run_details,
):
"""
Tests custom template search and rendering.
This test should check template matching when org={org}, course={course}, mode={mode}.
@@ -1130,28 +1138,44 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
course_id=unicode(self.course.id)
)
#create a org_mode_and_coursekey template language=null
self._create_custom_named_template('test_null_lang_template', org_id=1, mode='honor', course_key=unicode(self.course.id), language=None)
self._create_custom_named_template(
'test_null_lang_template', org_id=1, mode='honor', course_key=unicode(self.course.id), language=None,
)
#verify return template lang = null
response = self.client.get(test_url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'course name: test_null_lang_template')
#create a org_mode_and_coursekey template language=wrong_language
self._create_custom_named_template('test_wrong_lang_template', org_id=1, mode='honor', course_key=unicode(self.course.id), language=wrong_language)
self._create_custom_named_template(
'test_wrong_lang_template',
org_id=1,
mode='honor',
course_key=unicode(self.course.id),
language=wrong_language,
)
#verify returns null lang template
response = self.client.get(test_url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'course name: test_null_lang_template')
#create an org_mode_and_coursekey template language=''
self._create_custom_named_template('test_all_languages_template', org_id=1, mode='honor', course_key=unicode(self.course.id), language='')
self._create_custom_named_template(
'test_all_languages_template', org_id=1, mode='honor', course_key=unicode(self.course.id), language='',
)
#verify returns null lang template
response = self.client.get(test_url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'course name: test_all_languages_template')
#create a org_mode_and_coursekey template language=lang
self._create_custom_named_template('test_right_lang_template', org_id=1, mode='honor', course_key=unicode(self.course.id), language=right_language)
self._create_custom_named_template(
'test_right_lang_template',
org_id=1,
mode='honor',
course_key=unicode(self.course.id),
language=right_language,
)
# verify return right_language template
response = self.client.get(test_url)
self.assertEqual(response.status_code, 200)
@@ -1334,7 +1358,11 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
def test_certificate_custom_language_template_with_locale_language_from_catalogue(self, mock_get_org_id, mock_get_course_run_details):
def test_certificate_custom_language_template_with_locale_language_from_catalogue(
self,
mock_get_org_id,
mock_get_course_run_details,
):
"""
Tests custom template search if we have a single template for a course mode.
This test should check template matching when org=null, course=Null, mode={mode}.
@@ -1392,7 +1420,12 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
@ddt.data(True, False)
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
def test_certificate_custom_template_with_hours_of_effort(self, include_effort, mock_get_org_id, mock_get_course_run_details):
def test_certificate_custom_template_with_hours_of_effort(
self,
include_effort,
mock_get_org_id,
mock_get_course_run_details,
):
"""
Tests custom template properly retrieves and calculates Hours of Effort when the feature is enabled
"""