def test_initialize_bots__bot_is_first(self):
        result, account_1_id, bundle_id = register_user('bot',
                                                        '*****@*****.**',
                                                        '111111',
                                                        is_bot=True)
        result, account_2_id, bundle_id = register_user('test_user_3')

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage = LogicStorage()
        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1.id]
        hero_2 = storage.accounts_to_heroes[account_2.id]

        hero_2._model.level = 50
        self.assertEqual(hero_1.level, 1)

        MetaActionArenaPvP1x1Prototype.create(storage,
                                              hero_1,
                                              hero_2,
                                              bundle_id=self.bundle_id + 1)

        self.assertEqual(hero_1.level, 50)
        self.assertTrue(len(hero_1.abilities.all) > 1)
        self.assertEqual(hero_1.health, hero_1.max_health)
    def test_initialize_bots__second_create(self):
        result, account_1_id, bundle_id = register_user("test_user_3")
        result, account_2_id, bundle_id = register_user("bot", "*****@*****.**", "111111", is_bot=True)

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage = LogicStorage()
        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1.id]
        hero_2 = storage.accounts_to_heroes[account_2.id]

        hero_1._model.level = 50
        self.assertEqual(hero_2.level, 1)

        self.pvp_create_battle(account_1, account_2, BATTLE_1X1_STATE.PROCESSING)
        self.pvp_create_battle(account_2, account_1, BATTLE_1X1_STATE.PROCESSING)

        meta_action = MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=self.bundle_id + 1)
        meta_action.process_battle_ending()

        MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=self.bundle_id + 2)

        self.assertEqual(hero_2.level, 50)
        self.assertTrue(len(hero_2.abilities.all) > 1)
        self.assertEqual(hero_2.health, hero_2.max_health)
    def test_process_bot__flame_ability_not_used(self):
        result, account_1_id, bundle_id = register_user("bot", "*****@*****.**", "111111", is_bot=True)
        result, account_2_id, bundle_id = register_user("test_user_3")

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage = LogicStorage()
        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1.id]
        hero_2 = storage.accounts_to_heroes[account_2.id]

        MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=self.bundle_id + 1)

        self.assertEqual(hero_2.pvp.energy_speed, 1)

        with mock.patch(
            "the_tale.game.actions.meta_actions.MetaActionArenaPvP1x1Prototype.get_bot_pvp_properties",
            lambda a: {"priorities": {Flame.TYPE: 1}, "ability_chance": 1},
        ):
            with mock.patch("the_tale.game.pvp.abilities.Flame.use") as use:
                for i in xrange(100):
                    self.meta_action_battle.process_bot(hero_1, hero_2)

        self.assertEqual(use.call_count, 0)
示例#4
0
    def test_save_hero_data_with_meta_action(self):
        bundle_id = 666

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(self.storage, self.hero_1, self.hero_2, bundle_id=bundle_id)

        actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle)
        actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle)

        with mock.patch('the_tale.game.actions.meta_actions.MetaActionPrototype.save') as save_counter:
            self.storage._save_hero_data(self.hero_1.id)
            self.storage._save_hero_data(self.hero_2.id)

        self.assertEqual(save_counter.call_count, 0)

        self.storage.meta_actions.values()[0].updated = True
        with mock.patch('the_tale.game.actions.meta_actions.MetaActionPrototype.save', save_counter):
            self.storage._save_hero_data(self.hero_1.id)
            self.storage._save_hero_data(self.hero_2.id)

        self.assertEqual(save_counter.call_count, 0) # meta action saved by proxy actions

        self.hero_1.actions.updated = True
        self.hero_2.actions.updated = True

        with mock.patch('the_tale.game.actions.meta_actions.MetaActionPrototype.save', save_counter):
            self.storage._save_hero_data(self.hero_1.id)
            self.storage._save_hero_data(self.hero_2.id)

        self.assertEqual(save_counter.call_count, 2) # meta action saved by every proxy actions (see mock.patch)
    def setUp(self):
        super(MetaProxyActionForArenaPvP1x1Tests, self).setUp()

        create_test_map()

        result, account_1_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')
        result, account_2_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.storage = LogicStorage()
        self.storage.load_account_data(AccountPrototype.get_by_id(self.account_1.id))
        self.storage.load_account_data(AccountPrototype.get_by_id(self.account_2.id))

        self.hero_1 = self.storage.accounts_to_heroes[account_1_id]
        self.hero_2 = self.storage.accounts_to_heroes[account_2_id]

        self.action_idl_1 = self.hero_1.actions.current_action
        self.action_idl_2 = self.hero_2.actions.current_action

        self.pvp_create_battle(self.account_1, self.account_2, BATTLE_1X1_STATE.PROCESSING)
        self.pvp_create_battle(self.account_2, self.account_1, BATTLE_1X1_STATE.PROCESSING)

        self.bundle_id = 666

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(self.storage, self.hero_1, self.hero_2, bundle_id=self.bundle_id)

        self.action_proxy_1 = ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=self.bundle_id, meta_action=meta_action_battle)
        self.action_proxy_2 = ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=self.bundle_id, meta_action=meta_action_battle)

        self.storage.merge_bundles([self.action_idl_1.bundle_id, self.action_idl_2.bundle_id], self.bundle_id)

        self.meta_action_battle = self.storage.meta_actions.values()[0]
示例#6
0
    def test_load_account_data_with_meta_action(self):
        bundle_id = 666

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(self.storage, self.hero_1, self.hero_2, bundle_id=bundle_id)

        proxy_action_1 = actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle)
        proxy_action_2 = actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle)

        self.assertEqual(len(self.storage.meta_actions), 1)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 1)
        self.assertEqual(self.storage.meta_actions_to_actions[meta_action_battle.id], set([LogicStorage.get_action_uid(proxy_action_1),
                                                                                           LogicStorage.get_action_uid(proxy_action_2)]))

        self.storage.save_changed_data()

        storage = LogicStorage()
        storage.load_account_data(AccountPrototype.get_by_id(self.account_1.id))
        storage.load_account_data(AccountPrototype.get_by_id(self.account_2.id))

        self.assertEqual(len(storage.meta_actions), 1)
        self.assertEqual(len(storage.meta_actions_to_actions), 1)
        self.assertEqual(storage.meta_actions_to_actions[meta_action_battle.id], set([LogicStorage.get_action_uid(proxy_action_1),
                                                                                      LogicStorage.get_action_uid(proxy_action_2)]))

        self.assertEqual(storage.bundles_to_accounts, {self.hero_1.actions.current_action.bundle_id: set([self.account_1.id, self.account_2.id])})
    def test_initialize_bots__bot_is_first(self):
        result, account_1_id, bundle_id = register_user("bot", "*****@*****.**", "111111", is_bot=True)
        result, account_2_id, bundle_id = register_user("test_user_3")

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage = LogicStorage()
        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1.id]
        hero_2 = storage.accounts_to_heroes[account_2.id]

        hero_2._model.level = 50
        self.assertEqual(hero_1.level, 1)

        MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=self.bundle_id + 1)

        self.assertEqual(hero_1.level, 50)
        self.assertTrue(len(hero_1.abilities.all) > 1)
        self.assertEqual(hero_1.health, hero_1.max_health)
    def test_process_bot__flame_ability_not_used(self):
        result, account_1_id, bundle_id = register_user('bot',
                                                        '*****@*****.**',
                                                        '111111',
                                                        is_bot=True)
        result, account_2_id, bundle_id = register_user('test_user_3')

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage = LogicStorage()
        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1.id]
        hero_2 = storage.accounts_to_heroes[account_2.id]

        MetaActionArenaPvP1x1Prototype.create(storage,
                                              hero_1,
                                              hero_2,
                                              bundle_id=self.bundle_id + 1)

        self.assertEqual(hero_2.pvp.energy_speed, 1)

        with mock.patch(
                'the_tale.game.actions.meta_actions.MetaActionArenaPvP1x1Prototype.get_bot_pvp_properties',
                lambda a: {
                    'priorities': {
                        Flame.TYPE: 1
                    },
                    'ability_chance': 1
                }):
            with mock.patch('the_tale.game.pvp.abilities.Flame.use') as use:
                for i in xrange(100):
                    self.meta_action_battle.process_bot(hero_1, hero_2)

        self.assertEqual(use.call_count, 0)
    def test_initialize_bots__second_create(self):
        result, account_1_id, bundle_id = register_user('test_user_3')
        result, account_2_id, bundle_id = register_user('bot',
                                                        '*****@*****.**',
                                                        '111111',
                                                        is_bot=True)

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage = LogicStorage()
        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1.id]
        hero_2 = storage.accounts_to_heroes[account_2.id]

        hero_1._model.level = 50
        self.assertEqual(hero_2.level, 1)

        self.pvp_create_battle(account_1, account_2,
                               BATTLE_1X1_STATE.PROCESSING)
        self.pvp_create_battle(account_2, account_1,
                               BATTLE_1X1_STATE.PROCESSING)

        meta_action = MetaActionArenaPvP1x1Prototype.create(
            storage, hero_1, hero_2, bundle_id=self.bundle_id + 1)
        meta_action.process_battle_ending()

        MetaActionArenaPvP1x1Prototype.create(storage,
                                              hero_1,
                                              hero_2,
                                              bundle_id=self.bundle_id + 2)

        self.assertEqual(hero_2.level, 50)
        self.assertTrue(len(hero_2.abilities.all) > 1)
        self.assertEqual(hero_2.health, hero_2.max_health)
示例#10
0
    def test_load_account_data_with_meta_action(self):
        bundle_id = 666

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(
            self.storage, self.hero_1, self.hero_2, bundle_id=bundle_id)

        proxy_action_1 = actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_1,
            _bundle_id=bundle_id,
            meta_action=meta_action_battle)
        proxy_action_2 = actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_2,
            _bundle_id=bundle_id,
            meta_action=meta_action_battle)

        self.assertEqual(len(self.storage.meta_actions), 1)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 1)
        self.assertEqual(
            self.storage.meta_actions_to_actions[meta_action_battle.id],
            set([
                LogicStorage.get_action_uid(proxy_action_1),
                LogicStorage.get_action_uid(proxy_action_2)
            ]))

        self.storage.save_changed_data()

        storage = LogicStorage()
        storage.load_account_data(AccountPrototype.get_by_id(
            self.account_1.id))
        storage.load_account_data(AccountPrototype.get_by_id(
            self.account_2.id))

        self.assertEqual(len(storage.meta_actions), 1)
        self.assertEqual(len(storage.meta_actions_to_actions), 1)
        self.assertEqual(
            storage.meta_actions_to_actions[meta_action_battle.id],
            set([
                LogicStorage.get_action_uid(proxy_action_1),
                LogicStorage.get_action_uid(proxy_action_2)
            ]))

        self.assertEqual(
            storage.bundles_to_accounts, {
                self.hero_1.actions.current_action.bundle_id:
                set([self.account_1.id, self.account_2.id])
            })
示例#11
0
    def process_arena_pvp_1x1(self, bundle_id):  # pylint: disable=R0914
        from the_tale.accounts.prototypes import AccountPrototype
        from the_tale.game.actions.prototypes import ActionMetaProxyPrototype
        from the_tale.game.actions.meta_actions import MetaActionArenaPvP1x1Prototype
        from the_tale.game.logic_storage import LogicStorage
        from the_tale.game.pvp.prototypes import Battle1x1Prototype
        from the_tale.game.pvp.models import BATTLE_1X1_STATE

        storage = LogicStorage()

        account_1_id, account_2_id = list(self.members)

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1_id]
        hero_2 = storage.accounts_to_heroes[account_2_id]

        old_bundle_1_id = hero_1.actions.current_action.bundle_id
        old_bundle_2_id = hero_2.actions.current_action.bundle_id

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(
            storage, hero_1, hero_2, bundle_id=bundle_id)

        ActionMetaProxyPrototype.create(hero=hero_1,
                                        _bundle_id=bundle_id,
                                        meta_action=meta_action_battle)
        ActionMetaProxyPrototype.create(hero=hero_2,
                                        _bundle_id=bundle_id,
                                        meta_action=meta_action_battle)

        storage.merge_bundles([old_bundle_1_id, old_bundle_2_id], bundle_id)

        storage.save_bundle_data(bundle_id)

        battle_1 = Battle1x1Prototype.get_by_account_id(account_1_id)
        battle_1.state = BATTLE_1X1_STATE.PROCESSING
        battle_1.save()

        battle_2 = Battle1x1Prototype.get_by_account_id(account_2_id)
        battle_2.state = BATTLE_1X1_STATE.PROCESSING
        battle_2.save()
示例#12
0
    def test_save_hero_data_with_meta_action(self):
        bundle_id = 666

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(
            self.storage, self.hero_1, self.hero_2, bundle_id=bundle_id)

        actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_1,
            _bundle_id=bundle_id,
            meta_action=meta_action_battle)
        actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_2,
            _bundle_id=bundle_id,
            meta_action=meta_action_battle)

        with mock.patch(
                'the_tale.game.actions.meta_actions.MetaActionPrototype.save'
        ) as save_counter:
            self.storage._save_hero_data(self.hero_1.id)
            self.storage._save_hero_data(self.hero_2.id)

        self.assertEqual(save_counter.call_count, 0)

        self.storage.meta_actions.values()[0].updated = True
        with mock.patch(
                'the_tale.game.actions.meta_actions.MetaActionPrototype.save',
                save_counter):
            self.storage._save_hero_data(self.hero_1.id)
            self.storage._save_hero_data(self.hero_2.id)

        self.assertEqual(save_counter.call_count,
                         0)  # meta action saved by proxy actions

        self.hero_1.actions.updated = True
        self.hero_2.actions.updated = True

        with mock.patch(
                'the_tale.game.actions.meta_actions.MetaActionPrototype.save',
                save_counter):
            self.storage._save_hero_data(self.hero_1.id)
            self.storage._save_hero_data(self.hero_2.id)

        self.assertEqual(
            save_counter.call_count,
            2)  # meta action saved by every proxy actions (see mock.patch)
    def setUp(self):
        super(ArenaPvP1x1MetaActionTest, self).setUp()

        create_test_map()

        result, account_1_id, bundle_id = register_user('test_user_1')
        result, account_2_id, bundle_id = register_user('test_user_2')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        # for test data reset
        self.hero_1.health = self.hero_1.max_health / 2
        self.hero_1.pvp.set_advantage(1)
        self.hero_1.pvp.set_effectiveness(0.5)

        # for test data reset
        self.hero_2.pvp.set_advantage(1)
        self.hero_2.pvp.set_effectiveness(0.5)

        self.battle_1 = self.pvp_create_battle(self.account_1, self.account_2,
                                               BATTLE_1X1_STATE.PROCESSING)
        self.battle_1.calculate_rating = True
        self.battle_1.save()

        self.battle_2 = self.pvp_create_battle(self.account_2, self.account_1,
                                               BATTLE_1X1_STATE.PROCESSING)
        self.battle_2.calculate_rating = True
        self.battle_2.save()

        self.bundle_id = 666

        self.meta_action_battle = MetaActionArenaPvP1x1Prototype.create(
            self.storage, self.hero_1, self.hero_2, bundle_id=self.bundle_id)
        self.meta_action_battle.set_storage(self.storage)
    def setUp(self):
        super(ArenaPvP1x1MetaActionTest, self).setUp()

        create_test_map()

        result, account_1_id, bundle_id = register_user("test_user_1")
        result, account_2_id, bundle_id = register_user("test_user_2")

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        # for test data reset
        self.hero_1.health = self.hero_1.max_health / 2
        self.hero_1.pvp.set_advantage(1)
        self.hero_1.pvp.set_effectiveness(0.5)

        # for test data reset
        self.hero_2.pvp.set_advantage(1)
        self.hero_2.pvp.set_effectiveness(0.5)

        self.battle_1 = self.pvp_create_battle(self.account_1, self.account_2, BATTLE_1X1_STATE.PROCESSING)
        self.battle_1.calculate_rating = True
        self.battle_1.save()

        self.battle_2 = self.pvp_create_battle(self.account_2, self.account_1, BATTLE_1X1_STATE.PROCESSING)
        self.battle_2.calculate_rating = True
        self.battle_2.save()

        self.bundle_id = 666

        self.meta_action_battle = MetaActionArenaPvP1x1Prototype.create(
            self.storage, self.hero_1, self.hero_2, bundle_id=self.bundle_id
        )
        self.meta_action_battle.set_storage(self.storage)
示例#15
0
    def process_arena_pvp_1x1(self, bundle_id):  # pylint: disable=R0914
        from the_tale.accounts.prototypes import AccountPrototype
        from the_tale.game.actions.prototypes import ActionMetaProxyPrototype
        from the_tale.game.actions.meta_actions import MetaActionArenaPvP1x1Prototype
        from the_tale.game.logic_storage import LogicStorage
        from the_tale.game.pvp.prototypes import Battle1x1Prototype
        from the_tale.game.pvp.models import BATTLE_1X1_STATE

        storage = LogicStorage()

        account_1_id, account_2_id = list(self.members)

        account_1 = AccountPrototype.get_by_id(account_1_id)
        account_2 = AccountPrototype.get_by_id(account_2_id)

        storage.load_account_data(account_1)
        storage.load_account_data(account_2)

        hero_1 = storage.accounts_to_heroes[account_1_id]
        hero_2 = storage.accounts_to_heroes[account_2_id]

        old_bundle_1_id = hero_1.actions.current_action.bundle_id
        old_bundle_2_id = hero_2.actions.current_action.bundle_id

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(storage, hero_1, hero_2, bundle_id=bundle_id)

        ActionMetaProxyPrototype.create(hero=hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle)
        ActionMetaProxyPrototype.create(hero=hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle)

        storage.merge_bundles([old_bundle_1_id, old_bundle_2_id], bundle_id)

        storage.save_bundle_data(bundle_id)

        battle_1 = Battle1x1Prototype.get_by_account_id(account_1_id)
        battle_1.state = BATTLE_1X1_STATE.PROCESSING
        battle_1.save()

        battle_2 = Battle1x1Prototype.get_by_account_id(account_2_id)
        battle_2.state = BATTLE_1X1_STATE.PROCESSING
        battle_2.save()
示例#16
0
    def test_remove_action__metaaction(self):
        bundle_id = 666

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(self.storage, self.hero_1, self.hero_2, bundle_id=bundle_id)

        proxy_action_1 = actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle)
        proxy_action_2 = actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle)

        self.assertEqual(len(self.storage.meta_actions), 1)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 1)
        self.assertEqual(self.storage.meta_actions_to_actions[meta_action_battle.id], set([LogicStorage.get_action_uid(proxy_action_1),
                                                                                           LogicStorage.get_action_uid(proxy_action_2)]))

        self.storage.remove_action(proxy_action_2)

        self.assertEqual(len(self.storage.meta_actions), 1)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 1)
        self.assertEqual(self.storage.meta_actions_to_actions[meta_action_battle.id], set([LogicStorage.get_action_uid(proxy_action_1)]))

        self.storage.remove_action(proxy_action_1)

        self.assertEqual(len(self.storage.meta_actions), 0)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 0)
示例#17
0
    def test_remove_action__metaaction(self):
        bundle_id = 666

        meta_action_battle = MetaActionArenaPvP1x1Prototype.create(
            self.storage, self.hero_1, self.hero_2, bundle_id=bundle_id)

        proxy_action_1 = actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_1,
            _bundle_id=bundle_id,
            meta_action=meta_action_battle)
        proxy_action_2 = actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_2,
            _bundle_id=bundle_id,
            meta_action=meta_action_battle)

        self.assertEqual(len(self.storage.meta_actions), 1)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 1)
        self.assertEqual(
            self.storage.meta_actions_to_actions[meta_action_battle.id],
            set([
                LogicStorage.get_action_uid(proxy_action_1),
                LogicStorage.get_action_uid(proxy_action_2)
            ]))

        self.storage.remove_action(proxy_action_2)

        self.assertEqual(len(self.storage.meta_actions), 1)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 1)
        self.assertEqual(
            self.storage.meta_actions_to_actions[meta_action_battle.id],
            set([LogicStorage.get_action_uid(proxy_action_1)]))

        self.storage.remove_action(proxy_action_1)

        self.assertEqual(len(self.storage.meta_actions), 0)
        self.assertEqual(len(self.storage.meta_actions_to_actions), 0)