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
cccb5cd7
Commit
cccb5cd7
authored
Jul 11, 2014
by
Ben McMorran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Defensively checks that children exist in has_changes
parent
b781013b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
+5
-1
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+14
-0
No files found.
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
View file @
cccb5cd7
...
...
@@ -591,7 +591,11 @@ class DraftModuleStore(MongoModuleStore):
:return: True if the draft and published versions differ
"""
item
=
self
.
get_item
(
location
)
try
:
item
=
self
.
get_item
(
location
)
# defensively check that the parent's child actually exists
except
ItemNotFoundError
:
return
False
# don't check children if this block has changes (is not public)
if
self
.
compute_publish_state
(
item
)
!=
PublishState
.
public
:
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
cccb5cd7
...
...
@@ -534,6 +534,20 @@ class TestMongoModuleStore(unittest.TestCase):
self
.
draft_store
.
publish
(
location
,
self
.
dummy_user
)
self
.
assertFalse
(
self
.
draft_store
.
has_changes
(
location
))
def
test_has_changes_missing_child
(
self
):
"""
Tests that has_changes() returns False when a published parent points to a child that doesn't exist.
"""
location
=
Location
(
'edX'
,
'missing'
,
'2012_Fall'
,
'sequential'
,
'parent'
)
# Create the parent and point it to a fake child
parent
=
self
.
draft_store
.
create_and_save_xmodule
(
location
,
user_id
=
self
.
dummy_user
)
parent
.
children
+=
[
Location
(
'edX'
,
'missing'
,
'2012_Fall'
,
'vertical'
,
'does_not_exist'
)]
self
.
draft_store
.
update_item
(
parent
,
self
.
dummy_user
)
# Check the parent for changes should return False and not throw an exception
self
.
assertFalse
(
self
.
draft_store
.
has_changes
(
location
))
def
_create_test_tree
(
self
,
name
,
user_id
=
None
):
"""
Creates and returns a tree with the following structure:
...
...
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