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
bd65cfa8
Commit
bd65cfa8
authored
Aug 19, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed outdated template logic in ModuleStoreTestCase
parent
05b34098
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
22 deletions
+16
-22
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+16
-22
No files found.
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
bd65cfa8
...
@@ -110,10 +110,11 @@ def xml_store_config(data_dir):
...
@@ -110,10 +110,11 @@ def xml_store_config(data_dir):
class
ModuleStoreTestCase
(
TestCase
):
class
ModuleStoreTestCase
(
TestCase
):
""" Subclass for any test case that uses the mongodb
"""
module store. This populates a uniquely named modulestore
Subclass for any test case that uses a ModuleStore.
collection with templates before running the TestCase
and drops it they are finished. """
Ensures that the ModuleStore is cleaned before/after each test.
"""
@staticmethod
@staticmethod
def
update_course
(
course
,
data
):
def
update_course
(
course
,
data
):
...
@@ -132,24 +133,19 @@ class ModuleStoreTestCase(TestCase):
...
@@ -132,24 +133,19 @@ class ModuleStoreTestCase(TestCase):
return
updated_course
return
updated_course
@staticmethod
@staticmethod
def
flush_mongo_except_templates
():
def
drop_mongo_collection
():
"""
"""
Delete everything in the module store except templates
.
If using a Mongo-backed modulestore, drop the collection
.
"""
"""
store
=
modulestore
()
store
=
modulestore
()
# This query means: every item in the collection
if
hasattr
(
store
,
'collection'
):
# that is not a template
store
.
collection
.
drop
()
query
=
{
"_id.course"
:
{
"$ne"
:
"templates"
}}
# Remove everything except templates
store
.
collection
.
remove
(
query
)
store
.
collection
.
drop
()
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
"""
"""
Flush the
mongo store and set up templates
.
Flush the
ModuleStore
.
"""
"""
# Use a uuid to differentiate
# Use a uuid to differentiate
...
@@ -173,8 +169,7 @@ class ModuleStoreTestCase(TestCase):
...
@@ -173,8 +169,7 @@ class ModuleStoreTestCase(TestCase):
"""
"""
# Clean up by dropping the collection
# Clean up by dropping the collection
store
=
modulestore
()
cls
.
drop_mongo_collection
()
store
.
collection
.
drop
()
clear_existing_modulestores
()
clear_existing_modulestores
()
...
@@ -183,21 +178,20 @@ class ModuleStoreTestCase(TestCase):
...
@@ -183,21 +178,20 @@ class ModuleStoreTestCase(TestCase):
def
_pre_setup
(
self
):
def
_pre_setup
(
self
):
"""
"""
Remove everything but the templates
before each test.
Flush the ModuleStore
before each test.
"""
"""
# Flush
anything that is not a templat
e
# Flush
the Mongo modulestor
e
ModuleStoreTestCase
.
flush_mongo_except_templates
()
ModuleStoreTestCase
.
drop_mongo_collection
()
# Call superclass implementation
# Call superclass implementation
super
(
ModuleStoreTestCase
,
self
)
.
_pre_setup
()
super
(
ModuleStoreTestCase
,
self
)
.
_pre_setup
()
def
_post_teardown
(
self
):
def
_post_teardown
(
self
):
"""
"""
Flush
everything we created except the templates
.
Flush
the ModuleStore after each test
.
"""
"""
# Flush anything that is not a template
ModuleStoreTestCase
.
drop_mongo_collection
()
ModuleStoreTestCase
.
flush_mongo_except_templates
()
# Call superclass implementation
# Call superclass implementation
super
(
ModuleStoreTestCase
,
self
)
.
_post_teardown
()
super
(
ModuleStoreTestCase
,
self
)
.
_post_teardown
()
...
...
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