'Tests that connected asides could be stored, received and updated along with connected course items'

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

    if (default_store == ModuleStoreEnum.Type.mongo):
        raise SkipTest('asides    not    supported    in    old    mongo')
    self.initdb(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 = 'new_value11'
    aside1.field12 = 'new_value12'
    block_type2 = 'test_aside2'
    def_id = self.runtime.id_generator.create_definition(block_type1)
    usage_id = self.runtime.id_generator.create_usage(def_id)
    aside2 = AsideBar(scope_ids=ScopeIds('user', block_type2, def_id, usage_id), runtime=self.runtime)
    aside2.field21 = 'new_value21'
    published_xblock = self.store.create_item(self.user_id, self.course.id, 'vertical', block_id='test_vertical', asides=[aside1, aside2])
    def _check_asides(asides, field11, field12, field21, field22):
        '    Helper    function    to    check    asides    '
        self.assertEqual(len(asides), 2)
        self.assertEqual({type(asides[0]), type(asides[1])}, {AsideFoo, AsideBar})
        self.assertEqual(asides[0].field11, field11)
        self.assertEqual(asides[0].field12, field12)
        self.assertEqual(asides[1].field21, field21)
        self.assertEqual(asides[1].field22, field22)
    component = self.store.get_item(published_xblock.location)
    asides = component.runtime.get_asides(component)
    _check_asides(asides, 'new_value11', 'new_value12', 'new_value21', 'aside2_default_value2')
    asides[0].field11 = 'other_value11'
    self.store.update_item(component, self.user_id, asides=[asides[0]])
    cached_asides = component.runtime.get_asides(component)
    _check_asides(cached_asides, 'other_value11', 'new_value12', 'new_value21', 'aside2_default_value2')
    new_component = self.store.get_item(published_xblock.location)
    new_asides = new_component.runtime.get_asides(new_component)
    _check_asides(new_asides, 'other_value11', 'new_value12', 'new_value21', 'aside2_default_value2')
