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
b999714e
Commit
b999714e
authored
Dec 12, 2014
by
Jesse Zoldak
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6111 from edx/zoldak/modulestore-test-config
Unit test speed improvements
parents
cc377e8c
77bbd303
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
7 deletions
+26
-7
cms/djangoapps/contentstore/tests/test_crud.py
+16
-3
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+7
-2
lms/envs/test.py
+3
-2
No files found.
cms/djangoapps/contentstore/tests/test_crud.py
View file @
b999714e
import
unittest
from
opaque_keys.edx.locator
import
LocalId
from
xmodule
import
templates
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests
import
persistent_factories
...
...
@@ -7,10 +9,9 @@ from xmodule.course_module import CourseDescriptor
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
xmodule.seq_module
import
SequenceDescriptor
from
xmodule.capa_module
import
CapaDescriptor
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
LocalId
from
xmodule.contentstore.django
import
_CONTENTSTORE
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
DuplicateCourseError
from
xmodule.html_module
import
HtmlDescriptor
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
class
TemplateTests
(
unittest
.
TestCase
):
...
...
@@ -20,10 +21,22 @@ class TemplateTests(unittest.TestCase):
def
setUp
(
self
):
clear_existing_modulestores
()
# redundant w/ cleanup but someone was getting errors
self
.
addCleanup
(
ModuleStoreTestCase
.
drop_mongo_collections
)
self
.
addCleanup
(
self
.
_
drop_mongo_collections
)
self
.
addCleanup
(
clear_existing_modulestores
)
self
.
split_store
=
modulestore
()
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
split
)
@staticmethod
def
_drop_mongo_collections
():
"""
If using a Mongo-backed modulestore & contentstore, drop the collections.
"""
module_store
=
modulestore
()
if
hasattr
(
module_store
,
'_drop_database'
):
module_store
.
_drop_database
()
# pylint: disable=protected-access
_CONTENTSTORE
.
clear
()
if
hasattr
(
module_store
,
'close_connections'
):
module_store
.
close_connections
()
def
test_get_templates
(
self
):
found
=
templates
.
all_templates
()
self
.
assertIsNotNone
(
found
.
get
(
'course'
))
...
...
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
b999714e
...
...
@@ -7,6 +7,8 @@ import pytz
from
tempfile
import
mkdtemp
from
uuid
import
uuid4
from
mock
import
patch
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
...
...
@@ -276,10 +278,14 @@ class ModuleStoreTestCase(TestCase):
return
updated_course
@staticmethod
def
drop_mongo_collections
():
@patch
(
'xmodule.modulestore.django.create_modulestore_instance'
)
def
drop_mongo_collections
(
mock_create
):
"""
If using a Mongo-backed modulestore & contentstore, drop the collections.
"""
# Do not create the modulestore if it does not exist.
mock_create
.
return_value
=
None
module_store
=
modulestore
()
if
hasattr
(
module_store
,
'_drop_database'
):
module_store
.
_drop_database
()
# pylint: disable=protected-access
...
...
@@ -302,7 +308,6 @@ class ModuleStoreTestCase(TestCase):
"""
Flush the ModuleStore.
"""
# Flush the Mongo modulestore
self
.
drop_mongo_collections
()
...
...
lms/envs/test.py
View file @
b999714e
...
...
@@ -15,8 +15,9 @@ sessions. Assumes structure:
from
.common
import
*
import
os
from
path
import
path
from
warnings
import
filterwarnings
,
simplefilter
from
tempfile
import
mkdtemp
from
uuid
import
uuid4
from
warnings
import
filterwarnings
,
simplefilter
# mongo connection settings
MONGO_PORT_NUM
=
int
(
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_PORT'
,
'27017'
))
...
...
@@ -130,7 +131,7 @@ update_module_store_settings(
'fs_root'
:
TEST_ROOT
/
"data"
,
},
xml_store_options
=
{
'data_dir'
:
COMMON_TEST_DATA_ROOT
,
'data_dir'
:
mkdtemp
(),
# never inadvertently load all the XML courses
},
doc_store_settings
=
{
'host'
:
MONGO_HOST
,
...
...
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