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
505a3824
Commit
505a3824
authored
Mar 22, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-enable all the tests!
parent
d631509a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
28 deletions
+60
-28
cms/djangoapps/contentstore/tests/test_checklists.py
+17
-10
cms/djangoapps/contentstore/tests/test_utils.py
+41
-17
cms/djangoapps/contentstore/utils.py
+2
-1
No files found.
cms/djangoapps/contentstore/tests/test_checklists.py
View file @
505a3824
""" Unit tests for checklist methods in views.py. """
from
contentstore.utils
import
get_modulestore
,
get_url_reverse
from
contentstore.tests.test_course_settings
import
CourseTestCase
from
xmodule.modulestore.inheritance
import
own_metadata
...
...
@@ -5,16 +6,21 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
django.core.urlresolvers
import
reverse
import
json
class
ChecklistTestCase
(
CourseTestCase
):
""" Test for checklist get and put methods. """
def
setUp
(
self
):
""" Creates the test course. """
super
(
ChecklistTestCase
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
(
org
=
'mitX'
,
number
=
'333'
,
display_name
=
'Checklists Course'
)
def
get_persisted_checklists
(
self
):
""" Returns the checklists as persisted in the modulestore. """
modulestore
=
get_modulestore
(
self
.
course
.
location
)
return
modulestore
.
get_item
(
self
.
course
.
location
)
.
checklists
def
test_get_checklists
(
self
):
""" Tests the get checklists method. """
checklists_url
=
get_url_reverse
(
'Checklists'
,
self
.
course
)
response
=
self
.
client
.
get
(
checklists_url
)
self
.
assertContains
(
response
,
"Getting Started With Studio"
)
...
...
@@ -30,17 +36,17 @@ class ChecklistTestCase(CourseTestCase):
self
.
assertEquals
(
payload
,
response
.
content
)
def
test_update_checklists_no_index
(
self
):
# No checklist index, should return all of them.
""" No checklist index, should return all of them. """
update_url
=
reverse
(
'checklists_updates'
,
kwargs
=
{
'org'
:
self
.
course
.
location
.
org
,
'course'
:
self
.
course
.
location
.
course
,
'name'
:
self
.
course
.
location
.
name
})
'org'
:
self
.
course
.
location
.
org
,
'course'
:
self
.
course
.
location
.
course
,
'name'
:
self
.
course
.
location
.
name
})
returned_checklists
=
json
.
loads
(
self
.
client
.
get
(
update_url
)
.
content
)
self
.
assertListEqual
(
self
.
get_persisted_checklists
(),
returned_checklists
)
def
test_update_checklists_index_ignored_on_get
(
self
):
# Checklist index ignored on get.
""" Checklist index ignored on get. """
update_url
=
reverse
(
'checklists_updates'
,
kwargs
=
{
'org'
:
self
.
course
.
location
.
org
,
'course'
:
self
.
course
.
location
.
course
,
'name'
:
self
.
course
.
location
.
name
,
...
...
@@ -50,7 +56,7 @@ class ChecklistTestCase(CourseTestCase):
self
.
assertListEqual
(
self
.
get_persisted_checklists
(),
returned_checklists
)
def
test_update_checklists_post_no_index
(
self
):
# No checklist index, will error on post.
""" No checklist index, will error on post. """
update_url
=
reverse
(
'checklists_updates'
,
kwargs
=
{
'org'
:
self
.
course
.
location
.
org
,
'course'
:
self
.
course
.
location
.
course
,
'name'
:
self
.
course
.
location
.
name
})
...
...
@@ -58,7 +64,7 @@ class ChecklistTestCase(CourseTestCase):
self
.
assertContains
(
response
,
'Could not save checklist'
,
status_code
=
400
)
def
test_update_checklists_index_out_of_range
(
self
):
# Checklist index out of range, will error on post.
""" Checklist index out of range, will error on post. """
update_url
=
reverse
(
'checklists_updates'
,
kwargs
=
{
'org'
:
self
.
course
.
location
.
org
,
'course'
:
self
.
course
.
location
.
course
,
'name'
:
self
.
course
.
location
.
name
,
...
...
@@ -67,7 +73,7 @@ class ChecklistTestCase(CourseTestCase):
self
.
assertContains
(
response
,
'Could not save checklist'
,
status_code
=
400
)
def
test_update_checklists_index
(
self
):
# Check that an update of a particular checklist works.
""" Check that an update of a particular checklist works. """
update_url
=
reverse
(
'checklists_updates'
,
kwargs
=
{
'org'
:
self
.
course
.
location
.
org
,
'course'
:
self
.
course
.
location
.
course
,
'name'
:
self
.
course
.
location
.
name
,
...
...
@@ -81,10 +87,10 @@ class ChecklistTestCase(CourseTestCase):
self
.
assertEqual
(
self
.
get_persisted_checklists
()[
2
],
returned_checklist
)
def
test_update_checklists_delete_unsupported
(
self
):
# Delete operation is not supported.
""" Delete operation is not supported. """
update_url
=
reverse
(
'checklists_updates'
,
kwargs
=
{
'org'
:
self
.
course
.
location
.
org
,
'course'
:
self
.
course
.
location
.
course
,
'name'
:
self
.
course
.
location
.
name
,
'checklist_index'
:
100
})
response
=
self
.
client
.
delete
(
update_url
)
self
.
assertContains
(
response
,
'Unsupported request'
,
status_code
=
400
)
self
.
assertContains
(
response
,
'Unsupported request'
,
status_code
=
400
)
\ No newline at end of file
cms/djangoapps/contentstore/tests/test_utils.py
View file @
505a3824
""" Tests for utils. """
from
contentstore
import
utils
import
mock
from
django.test
import
TestCase
...
...
@@ -6,44 +7,66 @@ from .utils import ModuleStoreTestCase
class
LMSLinksTestCase
(
TestCase
):
""" Tests for LMS links. """
def
about_page_test
(
self
):
""" Get URL for about page. """
location
=
'i4x'
,
'mitX'
,
'101'
,
'course'
,
'test'
utils
.
get_course_id
=
mock
.
Mock
(
return_value
=
"mitX/101/test"
)
link
=
utils
.
get_lms_link_for_about_page
(
location
)
self
.
assertEquals
(
link
,
"//localhost:8000/courses/mitX/101/test/about"
)
def
ls_link_test
(
self
):
def
lms_link_test
(
self
):
""" Tests get_lms_link_for_item. """
location
=
'i4x'
,
'mitX'
,
'101'
,
'vertical'
,
'contacting_us'
utils
.
get_course_id
=
mock
.
Mock
(
return_value
=
"mitX/101/test"
)
link
=
utils
.
get_lms_link_for_item
(
location
,
False
)
self
.
assertEquals
(
link
,
"//localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us"
)
link
=
utils
.
get_lms_link_for_item
(
location
,
True
)
self
.
assertEquals
(
link
,
"//preview.localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us"
)
self
.
assertEquals
(
link
,
"//preview.localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us"
)
class
UrlReverseTestCase
(
ModuleStoreTestCase
):
""" Tests for get_url_reverse """
def
test_CoursePageNames
(
self
):
""" Test the defined course pages. """
course
=
CourseFactory
.
create
(
org
=
'mitX'
,
number
=
'666'
,
display_name
=
'URL Reverse Course'
)
self
.
assertEquals
(
'/manage_users/i4x://mitX/666/course/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'ManageUsers'
,
course
))
self
.
assertEquals
(
'/manage_users/i4x://mitX/666/course/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'ManageUsers'
,
course
)
)
self
.
assertEquals
(
'/mitX/666/settings-details/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'SettingsDetails'
,
course
))
self
.
assertEquals
(
'/mitX/666/settings-details/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'SettingsDetails'
,
course
)
)
self
.
assertEquals
(
'/mitX/666/settings-grading/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'SettingsGrading'
,
course
))
self
.
assertEquals
(
'/mitX/666/settings-grading/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'SettingsGrading'
,
course
)
)
self
.
assertEquals
(
'/mitX/666/course/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'CourseOutline'
,
course
))
self
.
assertEquals
(
'/mitX/666/course/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'CourseOutline'
,
course
)
)
self
.
assertEquals
(
'/mitX/666/checklists/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'Checklists'
,
course
))
self
.
assertEquals
(
'/mitX/666/checklists/URL_Reverse_Course'
,
utils
.
get_url_reverse
(
'Checklists'
,
course
)
)
def
test_unknown_passes_through
(
self
):
""" Test that unknown values pass through. """
course
=
CourseFactory
.
create
(
org
=
'mitX'
,
number
=
'666'
,
display_name
=
'URL Reverse Course'
)
self
.
assertEquals
(
'foobar'
,
utils
.
get_url_reverse
(
'foobar'
,
course
))
self
.
assertEquals
(
'https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about'
,
utils
.
get_url_reverse
(
'https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about'
,
course
))
self
.
assertEquals
(
'foobar'
,
utils
.
get_url_reverse
(
'foobar'
,
course
)
)
self
.
assertEquals
(
'https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about'
,
utils
.
get_url_reverse
(
'https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about'
,
course
)
)
\ No newline at end of file
cms/djangoapps/contentstore/utils.py
View file @
505a3824
...
...
@@ -179,12 +179,13 @@ def get_url_reverse(course_page_name, course_module):
return
reverse
(
url_name
,
kwargs
=
{
"location"
:
ctx_loc
})
elif
url_name
in
[
CoursePageNames
.
SettingsDetails
,
CoursePageNames
.
SettingsGrading
,
CoursePageNames
.
CourseOutline
,
CoursePageNames
.
Checklists
]:
return
reverse
(
url_name
,
kwargs
=
{
'org'
:
ctx_loc
.
org
,
'course'
:
ctx_loc
.
course
,
'name'
:
ctx_loc
.
name
})
return
reverse
(
url_name
,
kwargs
=
{
'org'
:
ctx_loc
.
org
,
'course'
:
ctx_loc
.
course
,
'name'
:
ctx_loc
.
name
})
else
:
return
course_page_name
class
CoursePageNames
:
""" Constants for pages that are recognized by get_url_reverse method. """
ManageUsers
=
"manage_users"
SettingsDetails
=
"settings_details"
SettingsGrading
=
"settings_grading"
...
...
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