From 63e885be555db14112ae5def079b228441f2e05b Mon Sep 17 00:00:00 2001 From: John Eskew Date: Fri, 29 Dec 2017 11:29:28 -0500 Subject: [PATCH] Test fixes for student Django app for v1.9 --- common/djangoapps/student/tests/test_login.py | 9 +++++---- common/djangoapps/student/tests/test_refunds.py | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/djangoapps/student/tests/test_login.py b/common/djangoapps/student/tests/test_login.py index a6c3d36a11..170a05d06d 100644 --- a/common/djangoapps/student/tests/test_login.py +++ b/common/djangoapps/student/tests/test_login.py @@ -18,6 +18,7 @@ from social_django.models import UserSocialAuth from openedx.core.djangoapps.external_auth.models import ExternalAuthMap from openedx.core.djangolib.testing.utils import CacheIsolationTestCase +from openedx.tests.util import expected_redirect_url from student.tests.factories import RegistrationFactory, UserFactory, UserProfileFactory from student.views import login_oauth_token from third_party_auth.tests.utils import ( @@ -489,7 +490,7 @@ class ExternalAuthShibTest(ModuleStoreTestCase): """ response = self.client.get(reverse('dashboard')) self.assertEqual(response.status_code, 302) - self.assertEqual(response['Location'], 'http://testserver/login?next=/dashboard') + self.assertEqual(response['Location'], expected_redirect_url('/login?next=/dashboard')) @unittest.skipUnless(settings.FEATURES.get('AUTH_USE_SHIB'), "AUTH_USE_SHIB not set") def test_externalauth_login_required_course_context(self): @@ -500,7 +501,7 @@ class ExternalAuthShibTest(ModuleStoreTestCase): TARGET_URL = reverse('courseware', args=[self.course.id.to_deprecated_string()]) # pylint: disable=invalid-name noshib_response = self.client.get(TARGET_URL, follow=True, HTTP_ACCEPT="text/html") self.assertEqual(noshib_response.redirect_chain[-1], - ('http://testserver/login?next={url}'.format(url=TARGET_URL), 302)) + (expected_redirect_url('/login?next={url}'.format(url=TARGET_URL)), 302)) self.assertContains(noshib_response, (u"Sign in or Register | {platform_name}" .format(platform_name=settings.PLATFORM_NAME))) self.assertEqual(noshib_response.status_code, 200) @@ -515,9 +516,9 @@ class ExternalAuthShibTest(ModuleStoreTestCase): # The 'courseware' page actually causes a redirect itself, so it's not the end of the chain and we # won't test its contents self.assertEqual(shib_response.redirect_chain[-3], - ('http://testserver/shib-login/?next={url}'.format(url=TARGET_URL_SHIB), 302)) + (expected_redirect_url('/shib-login/?next={url}'.format(url=TARGET_URL_SHIB)), 302)) self.assertEqual(shib_response.redirect_chain[-2], - ('http://testserver{url}'.format(url=TARGET_URL_SHIB), 302)) + (expected_redirect_url(TARGET_URL_SHIB), 302)) self.assertEqual(shib_response.status_code, 200) diff --git a/common/djangoapps/student/tests/test_refunds.py b/common/djangoapps/student/tests/test_refunds.py index ecf0a513e6..13dc34b1f5 100644 --- a/common/djangoapps/student/tests/test_refunds.py +++ b/common/djangoapps/student/tests/test_refunds.py @@ -147,12 +147,12 @@ class RefundableTest(SharedModuleStoreTestCase): ) self.enrollment.course_overview.start = course_start - self.enrollment.attributes.add(CourseEnrollmentAttribute( + self.enrollment.attributes.create( enrollment=self.enrollment, namespace='order', name='order_number', value=self.ORDER_NUMBER - )) + ) with patch('student.models.EnrollmentRefundConfiguration.current') as config: instance = config.return_value @@ -183,12 +183,12 @@ class RefundableTest(SharedModuleStoreTestCase): # creating multiple attributes for same order. for attribute_count in range(2): # pylint: disable=unused-variable - self.enrollment.attributes.add(CourseEnrollmentAttribute( + self.enrollment.attributes.create( enrollment=self.enrollment, namespace='order', name='order_number', value=self.ORDER_NUMBER - )) + ) self.client.login(username=self.user.username, password=self.USER_PASSWORD) resp = self.client.post(reverse('student.views.dashboard', args=[]))