-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RESTful refactoring of /course access continued #1542
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
from django.test.client import Client | ||
from django.test.utils import override_settings | ||
from django.core.cache import cache | ||
from django.core.urlresolvers import reverse | ||
|
||
from contentstore.tests.utils import parse_json, user, registration | ||
from contentstore.tests.utils import parse_json, user, registration, AjaxEnabledTestClient | ||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase | ||
from contentstore.tests.test_course_settings import CourseTestCase | ||
from xmodule.modulestore.tests.factories import CourseFactory | ||
|
@@ -82,12 +81,12 @@ def setUp(self): | |
self.email = '[email protected]' | ||
self.pw = 'xyz' | ||
self.username = 'testuser' | ||
self.client = Client() | ||
self.client = AjaxEnabledTestClient() | ||
# clear the cache so ratelimiting won't affect these tests | ||
cache.clear() | ||
|
||
def check_page_get(self, url, expected): | ||
resp = self.client.get(url) | ||
resp = self.client.get_html(url) | ||
self.assertEqual(resp.status_code, expected) | ||
return resp | ||
|
||
|
@@ -152,20 +151,20 @@ def test_login_link_on_activation_age(self): | |
def test_private_pages_auth(self): | ||
"""Make sure pages that do require login work.""" | ||
auth_pages = ( | ||
reverse('index'), | ||
'/course', | ||
) | ||
|
||
# These are pages that should just load when the user is logged in | ||
# (no data needed) | ||
simple_auth_pages = ( | ||
reverse('index'), | ||
'/course', | ||
) | ||
|
||
# need an activated user | ||
self.test_create_account() | ||
|
||
# Create a new session | ||
self.client = Client() | ||
self.client = AjaxEnabledTestClient() | ||
|
||
# Not logged in. Should redirect to login. | ||
print('Not logged in') | ||
|
@@ -184,7 +183,7 @@ def test_private_pages_auth(self): | |
def test_index_auth(self): | ||
|
||
# not logged in. Should return a redirect. | ||
resp = self.client.get(reverse('index')) | ||
resp = self.client.get_html('/course') | ||
self.assertEqual(resp.status_code, 302) | ||
|
||
# Logged in should work. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why all of these are replaced with get_html. It's definitely nice for the cases where we need to specify HTML (for the refactored methods), but I don't think we should call it universally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It certainly doesn't hurt and makes the test more equivalent to actual use.