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
3402c657
Commit
3402c657
authored
Apr 22, 2016
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use separate ContentStore databases for every test
parent
099ce130
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
+27
-1
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+26
-0
lms/envs/test.py
+1
-1
No files found.
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
3402c657
...
...
@@ -130,6 +130,27 @@ def split_mongo_store_config(data_dir):
return
store
def
contentstore_config
():
"""
Return a new configuration for the contentstore that is isolated
from other such configurations.
"""
return
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'DOC_STORE_CONFIG'
:
{
'host'
:
MONGO_HOST
,
'db'
:
'test_xcontent_{}'
.
format
(
uuid4
()
.
hex
),
'port'
:
MONGO_PORT_NUM
,
},
# allow for additional options that can be keyed on a name, e.g. 'trashcan'
'ADDITIONAL_OPTIONS'
:
{
'trashcan'
:
{
'bucket'
:
'trash_fs'
}
}
}
@patch
(
'xmodule.modulestore.django.create_modulestore_instance'
,
autospec
=
True
)
def
drop_mongo_collections
(
mock_create
):
"""
...
...
@@ -195,9 +216,11 @@ class ModuleStoreIsolationMixin(CacheIsolationMixin):
"""
MODULESTORE
=
functools
.
partial
(
mixed_store_config
,
mkdtemp_clean
(),
{})
CONTENTSTORE
=
functools
.
partial
(
contentstore_config
)
ENABLED_CACHES
=
[
'mongo_metadata_inheritance'
,
'loc_cache'
]
__settings_overrides
=
[]
__old_modulestores
=
[]
__old_contentstores
=
[]
@classmethod
def
start_modulestore_isolation
(
cls
):
...
...
@@ -209,9 +232,11 @@ class ModuleStoreIsolationMixin(CacheIsolationMixin):
cls
.
start_cache_isolation
()
override
=
override_settings
(
MODULESTORE
=
cls
.
MODULESTORE
(),
CONTENTSTORE
=
cls
.
CONTENTSTORE
(),
)
cls
.
__old_modulestores
.
append
(
copy
.
deepcopy
(
settings
.
MODULESTORE
))
cls
.
__old_contentstores
.
append
(
copy
.
deepcopy
(
settings
.
CONTENTSTORE
))
override
.
__enter__
()
cls
.
__settings_overrides
.
append
(
override
)
XMODULE_FACTORY_LOCK
.
enable
()
...
...
@@ -230,6 +255,7 @@ class ModuleStoreIsolationMixin(CacheIsolationMixin):
cls
.
__settings_overrides
.
pop
()
.
__exit__
(
None
,
None
,
None
)
assert
settings
.
MODULESTORE
==
cls
.
__old_modulestores
.
pop
()
assert
settings
.
CONTENTSTORE
==
cls
.
__old_contentstores
.
pop
()
cls
.
end_cache_isolation
()
...
...
lms/envs/test.py
View file @
3402c657
...
...
@@ -173,7 +173,7 @@ CONTENTSTORE = {
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'DOC_STORE_CONFIG'
:
{
'host'
:
MONGO_HOST
,
'db'
:
'
xcontent'
,
'db'
:
'
test_xcontent_{}'
.
format
(
THIS_UUID
)
,
'port'
:
MONGO_PORT_NUM
,
}
}
...
...
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