From 43789a925263d35e00ad94ce306ceeb36c0fa5eb Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Wed, 4 Dec 2013 15:53:01 -0500 Subject: [PATCH] Fixed test to ensure deletion on publish --- .../lib/xmodule/xmodule/modulestore/split_mongo/split.py | 9 +++++---- .../xmodule/modulestore/tests/test_split_modulestore.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py index 17e849a55c..ac515b1013 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py @@ -1166,20 +1166,21 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): if not all(parent in destination_blocks for parent in parents): raise ItemNotFoundError(parents) for parent_loc in parents: - orphans.union( + orphans.update( self._sync_children( source_structure['blocks'][parent_loc], destination_blocks[parent_loc], subtree_root )) # update/create the subtree and its children in destination (skipping blacklist) - orphans.union( + orphans.update( self._publish_subdag( user_id, subtree_root, source_structure['blocks'], destination_blocks, blacklist or [] ) ) # remove any remaining 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) # update the db @@ -1610,7 +1611,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): ) for child in destination_block['fields'].get('children', []): 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 return orphans @@ -1624,7 +1625,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): 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): for child in structure['blocks'][orphan]['fields'].get('children', []): diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py index bd09d2ddf4..2e89b761d2 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py @@ -1174,7 +1174,7 @@ class TestPublish(SplitModuleTest): modulestore().delete_item(self._usage(source_course, "problem3_2"), self.user) modulestore().xblock_publish(self.user, source_course, dest_course, ["head12345"], ["chapter2"]) 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): """