Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
102dcc08
Commit
102dcc08
authored
Aug 15, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a test for the wiki course redirection.
parent
9f770ef9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
lms/djangoapps/course_wiki/tests/__init__.py
+1
-0
lms/djangoapps/course_wiki/tests/tests.py
+72
-0
No files found.
lms/djangoapps/course_wiki/tests/__init__.py
0 → 100644
View file @
102dcc08
lms/djangoapps/course_wiki/tests/tests.py
0 → 100644
View file @
102dcc08
from
django.core.urlresolvers
import
reverse
from
override_settings
import
override_settings
import
xmodule.modulestore.django
from
courseware.tests.tests
import
PageLoader
,
TEST_DATA_XML_MODULESTORE
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.xml_importer
import
import_from_xml
@override_settings
(
MODULESTORE
=
TEST_DATA_XML_MODULESTORE
)
class
WikiRedirectTestCase
(
PageLoader
):
def
setUp
(
self
):
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
courses
=
modulestore
()
.
get_courses
()
def
find_course
(
name
):
"""Assumes the course is present"""
return
[
c
for
c
in
courses
if
c
.
location
.
course
==
name
][
0
]
self
.
full
=
find_course
(
"full"
)
self
.
toy
=
find_course
(
"toy"
)
# Create two accounts
self
.
student
=
'view@test.com'
self
.
instructor
=
'view2@test.com'
self
.
password
=
'foo'
self
.
create_account
(
'u1'
,
self
.
student
,
self
.
password
)
self
.
create_account
(
'u2'
,
self
.
instructor
,
self
.
password
)
self
.
activate_user
(
self
.
student
)
self
.
activate_user
(
self
.
instructor
)
def
test_wiki_redirect
(
self
):
"""
Test that an enrolled in student going from /courses/edX/toy/2012_Fall/profile
to /wiki/some/fake/wiki/page/ will redirect to
/courses/edX/toy/2012_Fall/wiki/some/fake/wiki/page/
Test that an unenrolled student going to /courses/edX/toy/2012_Fall/wiki/some/fake/wiki/page/
will be redirected to /wiki/some/fake/wiki/page/
"""
self
.
login
(
self
.
student
,
self
.
password
)
self
.
enroll
(
self
.
toy
)
referer
=
reverse
(
"profile"
,
kwargs
=
{
'course_id'
:
self
.
toy
.
id
})
destination
=
reverse
(
"wiki:get"
,
kwargs
=
{
'path'
:
'some/fake/wiki/page/'
})
redirected_to
=
referer
.
replace
(
"profile"
,
"wiki/some/fake/wiki/page/"
)
resp
=
self
.
client
.
get
(
destination
,
HTTP_REFERER
=
referer
)
self
.
assertEqual
(
resp
.
status_code
,
302
)
self
.
assertEqual
(
resp
[
'Location'
],
'http://testserver'
+
redirected_to
)
# Now we test that the student will be redirected away from that page if they are unenrolled
# We do this in the same test because we want to make sure the redirected_to is the same
self
.
unenroll
(
self
.
toy
)
resp
=
self
.
client
.
get
(
redirected_to
,
HTTP_REFERER
=
referer
)
print
"redirected_to"
,
redirected_to
self
.
assertEqual
(
resp
.
status_code
,
302
)
self
.
assertEqual
(
resp
[
'Location'
],
'http://testserver'
+
destination
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment