'Tests that connected asides will be cloned together with the parent courses'

@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
@XBlockAside.register_temp_plugin(AsideFoo, 'test_aside1')
@patch('xmodule.modulestore.split_mongo.caching_descriptor_system.CachingDescriptorSystem.applicable_aside_types', (lambda self, block: ['test_aside1']))
def test_clone_course_with_asides(self, default_store):

    if (default_store == ModuleStoreEnum.Type.mongo):
        raise SkipTest('asides    not    supported    in    old    mongo')
    with MongoContentstoreBuilder().build() as contentstore:
        self._initialize_mixed(contentstore=contentstore, mappings={})
        with self.store.default_store(default_store):
            block_type1 = 'test_aside1'
            def_id = self.runtime.id_generator.create_definition(block_type1)
            usage_id = self.runtime.id_generator.create_usage(def_id)
            aside1 = AsideFoo(scope_ids=ScopeIds('user', block_type1, def_id, usage_id), runtime=self.runtime)
            aside1.field11 = 'test1'
            source_course_key = self.store.make_course_key('org.source', 'course.source', 'run.source')
            self._create_course(source_course_key, asides=[aside1])
            dest_course_id = self.store.make_course_key('org.other', 'course.other', 'run.other')
            self.store.clone_course(source_course_key, dest_course_id, self.user_id)
        source_store = self.store._get_modulestore_by_type(default_store)
        self.assertCoursesEqual(source_store, source_course_key, source_store, dest_course_id)
        actual_items = source_store.get_items(dest_course_id, revision=ModuleStoreEnum.RevisionOption.published_only)
        chapter_is_found = False
        for block in actual_items:
            if (block.scope_ids.block_type == 'chapter'):
                asides = block.runtime.get_asides(block)
                self.assertEqual(len(asides), 1)
                self.assertEqual(asides[0].field11, 'test1')
                self.assertEqual(asides[0].field12, 'aside1_default_value2')
                chapter_is_found = True
                break
        self.assertTrue(chapter_is_found)
