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
50a8cf4a
Commit
50a8cf4a
authored
Nov 08, 2012
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for course creation
parent
e3d65a0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
cms/djangoapps/contentstore/tests/tests.py
+59
-0
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
50a8cf4a
...
@@ -208,3 +208,61 @@ class EditTestCase(ContentStoreTestCase):
...
@@ -208,3 +208,61 @@ class EditTestCase(ContentStoreTestCase):
def
test_edit_unit_full
(
self
):
def
test_edit_unit_full
(
self
):
self
.
check_edit_unit
(
'full'
)
self
.
check_edit_unit
(
'full'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MODULESTORE
)
class
CourseCreationTest
(
ContentStoreTestCase
):
"""Test new course creation code"""
def
setUp
(
self
):
uname
=
'testuser'
email
=
'edit@test.com'
password
=
'foo'
# Create the use so we can log them in.
# Note that we do not actually need to do anything
# for registration if we directly mark them active.
u
=
User
.
objects
.
create_user
(
uname
,
email
,
password
)
u
.
is_active
=
True
u
.
save
()
# Flush and initialize the module store
# It needs a course template because it creates a new course
# by cloning from the template.
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
drop
()
template_item
=
{
'_id'
:
{
'tag'
:
'i4x'
,
'org'
:
'edx'
,
'course'
:
'templates'
,
'category'
:
'course'
,
'name'
:
'Empty'
,
'revision'
:
None
}}
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
insert
(
template_item
)
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
self
.
post_data
=
{
'template'
:
'i4x://edx/templates/course/Empty'
,
'org'
:
'MITx'
,
'number'
:
'999'
,
'display_name'
:
'Robot Super Course'
,
}
def
test_create_course
(
self
):
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
data
[
'id'
],
'i4x://MITx/999/course/Robot_Super_Course'
)
def
test_create_course_duplicate_course
(
self
):
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
data
[
'ErrMsg'
],
'There is already a course defined with this name.'
)
def
test_create_course_duplicate_number
(
self
):
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
self
.
post_data
[
'display_name'
]
=
'Robot Super Course Two'
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
data
[
'ErrMsg'
],
'There is already a course defined with the same organization and course number.'
)
\ No newline at end of file
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