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
ce71a940
Commit
ce71a940
authored
Dec 23, 2014
by
Don Mitchell
Committed by
Andy Armstrong
Jan 15, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for get_parent across branches
parent
6fb45ef9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
27 deletions
+40
-27
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+6
-3
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+34
-24
No files found.
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
ce71a940
...
...
@@ -627,11 +627,9 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
def
_compute_metadata_inheritance_tree
(
self
,
course_id
):
'''
TODO (cdodge) This method can be deleted when the 'split module store' work has been completed
Find all inheritable fields from all xblocks in the course which may define inheritable data
'''
# get all collections in the course, this query should not return any leaf nodes
# note this is a bit ugly as when we add new categories of containers, we have to add it here
course_id
=
self
.
fill_in_run
(
course_id
)
query
=
SON
([
(
'_id.tag'
,
'i4x'
),
...
...
@@ -639,6 +637,9 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
(
'_id.course'
,
course_id
.
course
),
(
'_id.category'
,
{
'$in'
:
BLOCK_TYPES_WITH_CHILDREN
})
])
# if we're only dealing in the published branch, then only get published containers
if
self
.
get_branch_setting
()
==
ModuleStoreEnum
.
Branch
.
published_only
:
query
[
'_id.revision'
]
=
None
# we just want the Location, children, and inheritable metadata
record_filter
=
{
'_id'
:
1
,
'definition.children'
:
1
}
...
...
@@ -663,6 +664,8 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
location_url
=
unicode
(
location
)
if
location_url
in
results_by_url
:
# found either draft or live to complement the other revision
# FIXME this is wrong. If the child was moved in draft from one parent to the other, it will
# show up under both in this logic: https://openedx.atlassian.net/browse/TNL-1075
existing_children
=
results_by_url
[
location_url
]
.
get
(
'definition'
,
{})
.
get
(
'children'
,
[])
additional_children
=
result
.
get
(
'definition'
,
{})
.
get
(
'children'
,
[])
total_children
=
existing_children
+
additional_children
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
ce71a940
...
...
@@ -5,7 +5,6 @@ Unit tests for the Mixed Modulestore, with DDT for the various stores (Split, Dr
from
collections
import
namedtuple
import
datetime
import
ddt
from
importlib
import
import_module
import
itertools
import
mimetypes
from
uuid
import
uuid4
...
...
@@ -33,7 +32,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
CourseLocator
from
xmodule.exceptions
import
InvalidVersionError
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.draft_and_published
import
UnsupportedRevisionError
,
ModuleStoreDraftAndPublished
from
xmodule.modulestore.draft_and_published
import
UnsupportedRevisionError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
DuplicateCourseError
,
ReferentialIntegrityError
,
NoPathToItem
from
xmodule.modulestore.mixed
import
MixedModuleStore
from
xmodule.modulestore.search
import
path_to_location
...
...
@@ -920,28 +919,39 @@ class TestMixedModuleStore(CourseComparisonTest):
# publish the course
self
.
course
=
self
.
store
.
publish
(
self
.
course
.
location
,
self
.
user_id
)
# make drafts of verticals
self
.
store
.
convert_to_draft
(
self
.
vertical_x1a
,
self
.
user_id
)
self
.
store
.
convert_to_draft
(
self
.
vertical_y1a
,
self
.
user_id
)
# move child problem_x1a_1 to vertical_y1a
child_to_move_location
=
self
.
problem_x1a_1
new_parent_location
=
self
.
vertical_y1a
old_parent_location
=
self
.
vertical_x1a
old_parent
=
self
.
store
.
get_item
(
old_parent_location
)
old_parent
.
children
.
remove
(
child_to_move_location
.
replace
(
version_guid
=
old_parent
.
location
.
version_guid
))
self
.
store
.
update_item
(
old_parent
,
self
.
user_id
)
new_parent
=
self
.
store
.
get_item
(
new_parent_location
)
new_parent
.
children
.
append
(
child_to_move_location
.
replace
(
version_guid
=
new_parent
.
location
.
version_guid
))
self
.
store
.
update_item
(
new_parent
,
self
.
user_id
)
self
.
verify_get_parent_locations_results
([
(
child_to_move_location
,
new_parent_location
,
None
),
(
child_to_move_location
,
new_parent_location
,
ModuleStoreEnum
.
RevisionOption
.
draft_preferred
),
(
child_to_move_location
,
old_parent_location
.
for_branch
(
ModuleStoreEnum
.
BranchName
.
published
),
ModuleStoreEnum
.
RevisionOption
.
published_only
),
])
with
self
.
store
.
bulk_operations
(
self
.
course
.
id
):
# make drafts of verticals
self
.
store
.
convert_to_draft
(
self
.
vertical_x1a
,
self
.
user_id
)
self
.
store
.
convert_to_draft
(
self
.
vertical_y1a
,
self
.
user_id
)
# move child problem_x1a_1 to vertical_y1a
child_to_move_location
=
self
.
problem_x1a_1
new_parent_location
=
self
.
vertical_y1a
old_parent_location
=
self
.
vertical_x1a
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
):
old_parent
=
self
.
store
.
get_item
(
child_to_move_location
)
.
get_parent
()
self
.
assertEqual
(
old_parent_location
,
old_parent
.
location
)
child_to_move_contextualized
=
child_to_move_location
.
map_into_course
(
old_parent
.
location
.
course_key
)
old_parent
.
children
.
remove
(
child_to_move_contextualized
)
self
.
store
.
update_item
(
old_parent
,
self
.
user_id
)
new_parent
=
self
.
store
.
get_item
(
new_parent_location
)
new_parent
.
children
.
append
(
child_to_move_location
)
self
.
store
.
update_item
(
new_parent
,
self
.
user_id
)
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
):
self
.
assertEqual
(
new_parent_location
,
self
.
store
.
get_item
(
child_to_move_location
)
.
get_parent
()
.
location
)
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
published_only
):
self
.
assertEqual
(
old_parent_location
,
self
.
store
.
get_item
(
child_to_move_location
)
.
get_parent
()
.
location
)
self
.
verify_get_parent_locations_results
([
(
child_to_move_location
,
new_parent_location
,
None
),
(
child_to_move_location
,
new_parent_location
,
ModuleStoreEnum
.
RevisionOption
.
draft_preferred
),
(
child_to_move_location
,
old_parent_location
.
for_branch
(
ModuleStoreEnum
.
BranchName
.
published
),
ModuleStoreEnum
.
RevisionOption
.
published_only
),
])
# publish the course again
self
.
store
.
publish
(
self
.
course
.
location
,
self
.
user_id
)
...
...
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