'Test finding orphans.'

@ddt.data((ModuleStoreEnum.Type.mongo, 1, 0), (ModuleStoreEnum.Type.split, 2, 0))
@ddt.unpack
def test_get_orphans(self, default_ms, max_find, max_send):

    self.initdb(default_ms)
    course_id = self.course_locations[self.MONGO_COURSEID].course_key
    self._create_block_hierarchy()
    orphan_locations = [course_id.make_usage_key('chapter', 'OrphanChapter'), course_id.make_usage_key('vertical', 'OrphanVertical'), course_id.make_usage_key('problem', 'OrphanProblem'), course_id.make_usage_key('html', 'OrphanHTML')]
    detached_locations = [course_id.make_usage_key('static_tab', 'StaticTab'), course_id.make_usage_key('course_info', 'updates')]
    for location in (orphan_locations + detached_locations):
        self.store.create_item(self.user_id, location.course_key, location.block_type, block_id=location.block_id)
    with check_mongo_calls(max_find, max_send):
        found_orphans = self.store.get_orphans(self.course_locations[self.MONGO_COURSEID].course_key)
    self.assertItemsEqual(found_orphans, orphan_locations)
