Test fixes for student Django app for v1.9

This commit is contained in:
John Eskew
2017-12-29 11:29:28 -05:00
parent fc2d0fc61a
commit 63e885be55
2 changed files with 9 additions and 8 deletions

View File

@@ -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)

View File

@@ -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=[]))