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
41f5159b
Commit
41f5159b
authored
Mar 04, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test special code paths in create_item
parent
71ac8441
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
13 deletions
+38
-13
common/lib/xmodule/xmodule/modulestore/mixed.py
+2
-4
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+36
-9
No files found.
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
41f5159b
...
...
@@ -353,7 +353,8 @@ class MixedModuleStore(ModuleStoreWriteBase):
elif
isinstance
(
store
,
SplitMongoModuleStore
):
if
isinstance
(
course_or_parent_loc
,
basestring
):
# course_id
course_or_parent_loc
=
loc_mapper
()
.
translate_location_to_course_locator
(
course_or_parent_loc
,
None
# hardcode draft version until we figure out how we're handling branches from app
course_or_parent_loc
,
None
,
published
=
False
)
elif
not
isinstance
(
course_or_parent_loc
,
CourseLocator
):
raise
ValueError
(
u"Cannot create a child of {} in split. Wrong repr."
.
format
(
course_or_parent_loc
))
...
...
@@ -364,9 +365,6 @@ class MixedModuleStore(ModuleStoreWriteBase):
fields
.
update
(
kwargs
.
pop
(
'definition_data'
,
{}))
kwargs
[
'fields'
]
=
fields
if
not
kwargs
.
get
(
'block_id'
,
False
)
and
getattr
(
location
,
'name'
,
False
):
kwargs
[
'block_id'
]
=
getattr
(
location
,
'name'
)
xblock
=
store
.
create_item
(
course_or_parent_loc
,
category
,
user_id
,
**
kwargs
)
else
:
raise
NotImplementedError
(
u"Cannot create an item on store
%
s"
%
store
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
41f5159b
...
...
@@ -141,15 +141,6 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
self
.
store
=
MixedModuleStore
(
**
self
.
options
)
self
.
addCleanup
(
self
.
store
.
close_all_connections
)
def
generate_location
(
course_id
):
"""
Generate the locations for the given ids
"""
course_dict
=
Location
.
parse_course_id
(
course_id
)
course_dict
[
'tag'
]
=
'i4x'
course_dict
[
'category'
]
=
'course'
return
Location
(
course_dict
)
self
.
course_locations
=
{
course_id
:
generate_location
(
course_id
)
for
course_id
in
[
self
.
MONGO_COURSEID
,
self
.
XML_COURSEID1
,
self
.
XML_COURSEID2
]
...
...
@@ -351,6 +342,32 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
else
:
self
.
assertEqual
(
found_orphans
,
[
unicode
(
orphan
.
location
)])
@ddt.data
(
'split'
)
def
test_create_item_from_course_id
(
self
,
default_ms
):
"""
Test code paths missed by the above:
* passing an old-style course_id which has a loc map to split's create_item
"""
self
.
initdb
(
default_ms
)
# create loc_map entry
loc_mapper
()
.
translate_location
(
self
.
MONGO_COURSEID
,
generate_location
(
self
.
MONGO_COURSEID
))
orphan
=
self
.
store
.
create_item
(
self
.
MONGO_COURSEID
,
'problem'
,
block_id
=
'orphan'
)
self
.
assertEqual
(
orphan
.
location
.
version_agnostic
()
.
as_course_locator
(),
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
as_course_locator
()
)
@ddt.data
(
'direct'
)
def
test_create_item_from_parent_location
(
self
,
default_ms
):
"""
Test a code path missed by the above: passing an old-style location as parent but no
new location for the child
"""
self
.
initdb
(
default_ms
)
self
.
store
.
create_item
(
self
.
course_locations
[
self
.
MONGO_COURSEID
],
'problem'
,
block_id
=
'orphan'
)
orphans
=
self
.
store
.
get_orphans
(
self
.
course_locations
[
self
.
MONGO_COURSEID
],
None
)
self
.
assertEqual
(
len
(
orphans
),
0
,
"unexpected orphans: {}"
.
format
(
orphans
))
#=============================================================================================================
# General utils for not using django settings
#=============================================================================================================
...
...
@@ -378,3 +395,13 @@ def create_modulestore_instance(engine, doc_store_config, options, i18n_service=
doc_store_config
=
doc_store_config
,
**
options
)
def
generate_location
(
course_id
):
"""
Generate the locations for the given ids
"""
course_dict
=
Location
.
parse_course_id
(
course_id
)
course_dict
[
'tag'
]
=
'i4x'
course_dict
[
'category'
]
=
'course'
return
Location
(
course_dict
)
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