From 30a2ae8aec26bd68267da62fe6ec66debbc79fc3 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 31 Mar 2020 23:48:37 +0500 Subject: [PATCH] BOM-1438 Fix course_id string. --- lms/djangoapps/commerce/tests/test_views.py | 8 ++++++-- lms/djangoapps/support/tests/test_views.py | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/commerce/tests/test_views.py b/lms/djangoapps/commerce/tests/test_views.py index 7f5c55dd55..628e86c700 100644 --- a/lms/djangoapps/commerce/tests/test_views.py +++ b/lms/djangoapps/commerce/tests/test_views.py @@ -63,13 +63,17 @@ class ReceiptViewTests(UserMixin, ModuleStoreTestCase): """ # Enroll as verified in the course with the current user. CourseEnrollment.enroll(self.user, self.course.id, mode=CourseMode.VERIFIED) - response = self.client.get(reverse('commerce:user_verification_status'), data={'course_id': self.course.id}) + response = self.client.get( + reverse('commerce:user_verification_status'), data={'course_id': str(self.course.id)} + ) json_data = json.loads(response.content.decode('utf-8')) self.assertEqual(json_data['is_verification_required'], True) # Enroll as honor in the course with the current user. CourseEnrollment.enroll(self.user, self.course.id, mode=CourseMode.HONOR) - response = self.client.get(reverse('commerce:user_verification_status'), data={'course_id': self.course.id}) + response = self.client.get( + reverse('commerce:user_verification_status'), data={'course_id': str(self.course.id)} + ) json_data = json.loads(response.content.decode('utf-8')) self.assertEqual(json_data['is_verification_required'], False) diff --git a/lms/djangoapps/support/tests/test_views.py b/lms/djangoapps/support/tests/test_views.py index 30110f68c5..04d2dcd91b 100644 --- a/lms/djangoapps/support/tests/test_views.py +++ b/lms/djangoapps/support/tests/test_views.py @@ -308,7 +308,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase self.assert_enrollment(CourseMode.VERIFIED) @ddt.data( - ({}, r"The field \"'\w+'\" is required."), # The double quoting goes away in Django 2.0.1 + ({}, r"The field \w+ is required."), ({'course_id': 'bad course key'}, 'Could not parse course key.'), ({ 'course_id': 'course-v1:TestX+T101+2015', @@ -334,10 +334,13 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase # `self` isn't available from within the DDT declaration, so # assign the course ID here if 'course_id' in data and data['course_id'] is None: - data['course_id'] = six.text_type(self.course.id) + data['course_id'] = str(self.course.id) response = self.client.post(self.url, data) + self.assertEqual(response.status_code, 400) - self.assertIsNotNone(re.match(error_message, response.content.decode('utf-8'))) + self.assertIsNotNone( + re.match(error_message, response.content.decode('utf-8').replace("'", '').replace('"', '')) + ) self.assert_enrollment(CourseMode.AUDIT) self.assertIsNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))