'Tests that connected asides will be removed together with the connected items'

@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_delete_item_with_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'
    published_xblock = self.store.create_item(self.user_id, self.course.id, 'vertical', block_id='test_vertical', asides=[aside1])
    asides = published_xblock.runtime.get_asides(published_xblock)
    self.assertEquals(asides[0].field11, 'new_value11')
    self.assertEquals(asides[0].field12, 'new_value12')
    self.store.delete_item(published_xblock.location, self.user_id)
    published_xblock2 = self.store.create_item(self.user_id, self.course.id, 'vertical', block_id='test_vertical')
    asides2 = published_xblock2.runtime.get_asides(published_xblock2)
    self.assertEquals(asides2[0].field11, 'aside1_default_value1')
    self.assertEquals(asides2[0].field12, 'aside1_default_value2')
