Commit 43789a92 by Don Mitchell

Fixed test to ensure deletion on publish

parent 7a4204b7
...@@ -1166,20 +1166,21 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): ...@@ -1166,20 +1166,21 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
if not all(parent in destination_blocks for parent in parents): if not all(parent in destination_blocks for parent in parents):
raise ItemNotFoundError(parents) raise ItemNotFoundError(parents)
for parent_loc in parents: for parent_loc in parents:
orphans.union( orphans.update(
self._sync_children( self._sync_children(
source_structure['blocks'][parent_loc], source_structure['blocks'][parent_loc],
destination_blocks[parent_loc], destination_blocks[parent_loc],
subtree_root subtree_root
)) ))
# update/create the subtree and its children in destination (skipping blacklist) # update/create the subtree and its children in destination (skipping blacklist)
orphans.union( orphans.update(
self._publish_subdag( self._publish_subdag(
user_id, subtree_root, source_structure['blocks'], destination_blocks, blacklist or [] user_id, subtree_root, source_structure['blocks'], destination_blocks, blacklist or []
) )
) )
# remove any remaining orphans # remove any remaining orphans
for orphan in orphans: for orphan in orphans:
# orphans will include moved as well as deleted xblocks. Only delete the deleted ones.
self._delete_if_true_orphan(orphan, destination_structure) self._delete_if_true_orphan(orphan, destination_structure)
# update the db # update the db
...@@ -1610,7 +1611,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): ...@@ -1610,7 +1611,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
) )
for child in destination_block['fields'].get('children', []): for child in destination_block['fields'].get('children', []):
if child not in blacklist: if child not in blacklist:
orphans.union(self._publish_subdag(user_id, child, source_blocks, destination_blocks, blacklist)) orphans.update(self._publish_subdag(user_id, child, source_blocks, destination_blocks, blacklist))
destination_blocks[block_id] = destination_block destination_blocks[block_id] = destination_block
return orphans return orphans
...@@ -1624,7 +1625,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): ...@@ -1624,7 +1625,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
def _delete_if_true_orphan(self, orphan, structure): def _delete_if_true_orphan(self, orphan, structure):
""" """
Delete the orphan and any of its descendants which no longer have parents Delete the orphan and any of its descendants which no longer have parents.
""" """
if not self._get_parents_from_structure(orphan, structure): if not self._get_parents_from_structure(orphan, structure):
for child in structure['blocks'][orphan]['fields'].get('children', []): for child in structure['blocks'][orphan]['fields'].get('children', []):
......
...@@ -1174,7 +1174,7 @@ class TestPublish(SplitModuleTest): ...@@ -1174,7 +1174,7 @@ class TestPublish(SplitModuleTest):
modulestore().delete_item(self._usage(source_course, "problem3_2"), self.user) modulestore().delete_item(self._usage(source_course, "problem3_2"), self.user)
modulestore().xblock_publish(self.user, source_course, dest_course, ["head12345"], ["chapter2"]) modulestore().xblock_publish(self.user, source_course, dest_course, ["head12345"], ["chapter2"])
expected = ["head12345", "chapter1", "chapter3", "problem1"] expected = ["head12345", "chapter1", "chapter3", "problem1"]
self._check_course(source_course, dest_course, expected, ["chapter2"]) self._check_course(source_course, dest_course, expected, ["chapter2", "problem3_2"])
def _check_course(self, source_course_loc, dest_course_loc, expected_blocks, unexpected_blocks): def _check_course(self, source_course_loc, dest_course_loc, expected_blocks, unexpected_blocks):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment