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
5a6b0392
Commit
5a6b0392
authored
Feb 02, 2013
by
Jay Zoldak
Committed by
Jay Zoldak
Feb 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganize the CmsTestCase subclass
parent
2c5a7ccd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
21 deletions
+35
-21
cms/djangoapps/contentstore/tests/tests.py
+2
-21
cms/djangoapps/contentstore/tests/utils.py
+33
-0
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
5a6b0392
...
...
@@ -29,6 +29,7 @@ from xmodule.course_module import CourseDescriptor
from
xmodule.seq_module
import
SequenceDescriptor
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
.utils
import
CmsTestCase
def
parse_json
(
response
):
"""Parse response, which is assumed to be json"""
...
...
@@ -196,7 +197,7 @@ TEST_DATA_MODULESTORE['default']['OPTIONS']['fs_root'] = path('common/test/data'
TEST_DATA_MODULESTORE
[
'direct'
][
'OPTIONS'
][
'fs_root'
]
=
path
(
'common/test/data'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MODULESTORE
)
class
ContentStoreTest
(
TestCase
):
class
ContentStoreTest
(
Cms
TestCase
):
def
setUp
(
self
):
uname
=
'testuser'
...
...
@@ -213,17 +214,6 @@ class ContentStoreTest(TestCase):
self
.
user
.
is_staff
=
True
self
.
user
.
save
()
# Flush and initialize the module store
# It needs the templates because it creates new records
# by cloning from the template.
# Note that if your test module gets in some weird state
# (though it shouldn't), do this manually
# from the bash shell to drop it:
# $ mongo test_xmodule --eval "db.dropDatabase()"
_MODULESTORES
=
{}
modulestore
()
.
collection
.
drop
()
update_templates
()
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
...
...
@@ -234,15 +224,6 @@ class ContentStoreTest(TestCase):
'display_name'
:
'Robot Super Course'
,
}
def
tearDown
(
self
):
# Make sure you flush out the test modulestore after the end
# of the last test because otherwise on the next run
# cms/djangoapps/contentstore/__init__.py
# update_templates() will try to update the templates
# via upsert and it sometimes seems to be messing things up.
_MODULESTORES
=
{}
modulestore
()
.
collection
.
drop
()
def
test_create_course
(
self
):
"""Test new course creation - happy path"""
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
...
...
cms/djangoapps/contentstore/tests/utils.py
0 → 100644
View file @
5a6b0392
from
django.test
import
TestCase
from
xmodule.modulestore.django
import
modulestore
,
_MODULESTORES
from
xmodule.templates
import
update_templates
# Subclass TestCase and use to initialize the contentstore
class
CmsTestCase
(
TestCase
):
""" Subclass for any test case that uses the mongodb
module store. This clears it out before running the TestCase
and reinitilizes it with the templates afterwards. """
def
_pre_setup
(
self
):
super
(
CmsTestCase
,
self
)
.
_pre_setup
()
# Flush and initialize the module store
# It needs the templates because it creates new records
# by cloning from the template.
# Note that if your test module gets in some weird state
# (though it shouldn't), do this manually
# from the bash shell to drop it:
# $ mongo test_xmodule --eval "db.dropDatabase()"
_MODULESTORES
=
{}
modulestore
()
.
collection
.
drop
()
update_templates
()
def
_post_teardown
(
self
):
# Make sure you flush out the test modulestore after the end
# of the last test because otherwise on the next run
# cms/djangoapps/contentstore/__init__.py
# update_templates() will try to update the templates
# via upsert and it sometimes seems to be messing things up.
_MODULESTORES
=
{}
modulestore
()
.
collection
.
drop
()
super
(
CmsTestCase
,
self
)
.
_post_teardown
()
\ 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