'Tests delete draft item create no orphans in course'

@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_delete_draft_item_orphans(self, default_store):

    self.initdb(default_store)
    course_locator = self.course.id
    chapter = self.store.create_child(self.user_id, self.course.location, 'chapter', block_id='section_one')
    sequential = self.store.create_child(self.user_id, chapter.location, 'sequential', block_id='subsection_one')
    vertical = self.store.create_child(self.user_id, sequential.location, 'vertical', block_id='moon_unit')
    problem = self.store.create_child(self.user_id, vertical.location, 'problem', block_id='problem')
    self.store.publish(chapter.location, self.user_id)
    self.assertFalse(self._has_changes(chapter.location))
    self.assertFalse(self._has_changes(sequential.location))
    self.assertFalse(self._has_changes(vertical.location))
    self.assertFalse(self._has_changes(problem.location))
    course_orphans = self.store.get_orphans(course_locator)
    self.assertEqual(len(course_orphans), 0)
    problem.display_name = 'changed'
    problem = self.store.update_item(problem, self.user_id)
    self.assertTrue(self._has_changes(vertical.location))
    self.assertTrue(self._has_changes(problem.location))
    self.store.delete_item(vertical.location, self.user_id)
    course_orphans = self.store.get_orphans(course_locator)
    if (default_store == ModuleStoreEnum.Type.mongo):
        self.assertEqual(len(course_orphans), 1)
    else:
        self.assertEqual(len(course_orphans), 0)
    course_locator_publish = course_locator.for_branch(ModuleStoreEnum.BranchName.published)
    course_publish_orphans = self.store.get_orphans(course_locator_publish)
    if (default_store == ModuleStoreEnum.Type.mongo):
        self.assertEqual(len(course_publish_orphans), 1)
    else:
        self.assertEqual(len(course_publish_orphans), 0)
