本文整理汇总了Python中the_tale.game.logic_storage.LogicStorage.load_account_data方法的典型用法代码示例。如果您正苦于以下问题:Python LogicStorage.load_account_data方法的具体用法?Python LogicStorage.load_account_data怎么用?Python LogicStorage.load_account_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.game.logic_storage.LogicStorage
的用法示例。
在下文中一共展示了LogicStorage.load_account_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChooseRequestsTests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class ChooseRequestsTests(testcase.TestCase, QuestTestsMixin):
def setUp(self):
super(ChooseRequestsTests, self).setUp()
create_test_map()
register_user('test_user', '[email protected]', '111111')
account = AccountPrototype.get_by_email('[email protected]')
self.storage = LogicStorage()
self.storage.load_account_data(AccountPrototype.get_by_id(account.id))
self.hero =self.storage.accounts_to_heroes[account.id]
self.choice_uid = '[ns-0]choice_1'
self.option_uid = '#option<[ns-0]choice_1, [ns-0]choice_2>'
@mock.patch('questgen.quests.quests_base.QuestsBase._available_quests', lambda *argv, **kwargs: [QuestWith2ChoicePoints])
def test_choose_no_account(self):
self.turn_to_quest(self.storage, self.hero.id)
response = self.client.post(url('game:quests:api-choose', option_uid=self.option_uid, api_version='1.0', api_client=project_settings.API_CLIENT))
self.check_ajax_error(response, 'common.login_required')
@mock.patch('questgen.quests.quests_base.QuestsBase._available_quests', lambda *argv, **kwargs: [QuestWith2ChoicePoints])
def test_choose_processing(self):
self.turn_to_quest(self.storage, self.hero.id)
self.request_login('[email protected]')
response = self.client.post(url('game:quests:api-choose', option_uid=self.option_uid, api_version='1.0', api_client=project_settings.API_CLIENT))
task = PostponedTaskPrototype._db_get_object(0)
self.check_ajax_processing(response, task.status_url)
self.assertEqual(PostponedTask.objects.all().count(), 1)
示例2: test_load_account_data_with_meta_action
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
def test_load_account_data_with_meta_action(self):
bundle_id = 666
meta_action_battle = meta_actions.ArenaPvP1x1.create(self.storage, self.hero_1, self.hero_2)
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.uid], set([LogicStorage.get_action_uid(proxy_action_1),
LogicStorage.get_action_uid(proxy_action_2)]))
self.storage.save_changed_data()
self.assertIs(self.hero_1.actions.current_action.meta_action, self.hero_2.actions.current_action.meta_action)
self.assertIs(self.hero_1.actions.current_action.saved_meta_action, self.hero_2.actions.current_action.saved_meta_action)
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.uid], 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])})
hero_1 = storage.accounts_to_heroes[self.account_1.id]
hero_2 = storage.accounts_to_heroes[self.account_2.id]
self.assertIs(hero_1.actions.current_action.meta_action, hero_2.actions.current_action.meta_action)
self.assertIsNot(hero_1.actions.current_action.saved_meta_action, hero_2.actions.current_action.saved_meta_action)
self.assertEqual(hero_1.actions.current_action.saved_meta_action.serialize(), hero_2.actions.current_action.saved_meta_action.serialize())
示例3: HelpPlaceMixin
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class HelpPlaceMixin(CardsTestMixin):
CARD = None
def setUp(self):
super(HelpPlaceMixin, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
def test_use(self):
with self.check_delta(lambda: self.hero.places_history._get_places_statisitcs().get(self.place_1.id, 0), self.CARD.HELPS):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero, place_id=self.place_1.id))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
def test_wrong_place(self):
with self.check_not_changed(lambda: self.hero.places_history._get_places_statisitcs().get(self.place_1.id, 0)):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero, place_id=666))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ()))
示例4: test_initialize_bots__second_create
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
def test_initialize_bots__second_create(self):
account_1 = self.accounts_factory.create_account()
account_2 = self.accounts_factory.create_account(is_bot=True)
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.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 = meta_actions.ArenaPvP1x1.create(storage, hero_1, hero_2)
meta_action.process_battle_ending()
meta_actions.ArenaPvP1x1.create(storage, hero_1, hero_2)
self.assertEqual(hero_2.level, 50)
self.assertTrue(len(hero_2.abilities.all) > 1)
self.assertEqual(hero_2.health, hero_2.max_health)
示例5: AddGoldTestMixin
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class AddGoldTestMixin(CardsTestMixin):
CARD = None
def setUp(self):
super(AddGoldTestMixin, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
def test_use(self):
with self.check_delta(lambda: self.hero.money, self.CARD.GOLD):
with self.check_delta(lambda: self.hero.statistics.money_earned_from_help, self.CARD.GOLD):
with self.check_delta(lambda: self.hero.statistics.money_earned, self.CARD.GOLD):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
示例6: ArenaPvP1x1AcceptBaseTests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class ArenaPvP1x1AcceptBaseTests(UseAbilityTaskMixin, testcase.TestCase):
def setUp(self):
super(ArenaPvP1x1AcceptBaseTests, self).setUp()
self.p1, self.p2, self.p3 = create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
result, account_2_id, bundle_id = register_user('test_user_2', '[email protected]', '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(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]
environment.deinitialize()
environment.initialize()
self.pvp_balancer = environment.workers.pvp_balancer
self.pvp_balancer.process_initialize('pvp_balancer')
self.battle = self.pvp_balancer.add_to_arena_queue(self.hero_1.id)
示例7: test_process_bot__flame_ability_not_used
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
def test_process_bot__flame_ability_not_used(self):
result, account_1_id, bundle_id = register_user("bot", "[email protected]", "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)
示例8: ResetPreferenceAllTests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class ResetPreferenceAllTests(CardsTestMixin, testcase.TestCase):
CARD = effects.PreferencesCooldownsResetAll
def setUp(self):
super(ResetPreferenceAllTests, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user("test_user", "[email protected]", "111111")
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
for preference in PREFERENCE_TYPE.records:
self.hero.preferences._set(preference, self.hero.preferences._get(preference))
self.card = self.CARD()
def test_use(self):
for preference in PREFERENCE_TYPE.records:
self.assertFalse(self.hero.preferences.can_update(preference, datetime.datetime.now()))
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ())
)
for preference in PREFERENCE_TYPE.records:
self.assertTrue(self.hero.preferences.can_update(preference, datetime.datetime.now()))
示例9: LevelUpTest
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class LevelUpTest(testcase.TestCase, CardsTestMixin):
CARD = LevelUp
def setUp(self):
super(LevelUpTest, self).setUp()
create_test_map()
result, account_1_id, bundle_id = register_user('test_user', '[email protected]', '111111')
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.card = self.CARD()
def test_use(self):
self.hero.add_experience(self.hero.experience_to_next_level / 2)
self.assertTrue(self.hero.experience > 0)
self.assertEqual(self.hero.level, 1)
with self.check_not_changed(lambda: self.hero.experience):
with self.check_delta(lambda: self.hero.level, 1):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
示例10: test_initialize_bots__second_create
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
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", "[email protected]", "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)
示例11: BuyRandomPremiumChestTask__EpicArtifact_Tests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class BuyRandomPremiumChestTask__EpicArtifact_Tests(base_buy_task._BaseBuyHeroMethodPosponedTaskTests):
def setUp(self):
super(BuyRandomPremiumChestTask__EpicArtifact_Tests, self).setUp()
self.task = BuyRandomPremiumChest(account_id=self.account.id,
transaction=self.transaction)
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.cmd_update_with_account_data__call_count = 0
self.accounts_manages_worker = False
self.supervisor_worker = True
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.assertEqual(self.hero.bag.occupation, 0)
def _get_expected_arguments(self):
return {}
def _check_not_used(self):
self.assertEqual(self.hero.bag.occupation, 0)
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 0)
def _check_used(self):
self.assertEqual(self.hero.bag.occupation, 1)
self.assertTrue(self.hero.bag.values()[0].rarity.is_EPIC)
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 1)
示例12: BuyRandomPremiumChestTask__Energy_Tests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class BuyRandomPremiumChestTask__Energy_Tests(base_buy_task._BaseBuyHeroMethodPosponedTaskTests):
def setUp(self):
super(BuyRandomPremiumChestTask__Energy_Tests, self).setUp()
self.task = BuyRandomPremiumChest(account_id=self.account.id,
transaction=self.transaction)
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.cmd_update_with_account_data__call_count = 0
self.accounts_manages_worker = False
self.supervisor_worker = True
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.hero.energy_bonus = 0
def _get_expected_arguments(self):
return {}
def _check_not_used(self):
self.assertEqual(self.hero.energy_bonus, 0)
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 0)
def _check_used(self):
self.assertEqual(self.hero.energy_bonus, relations.RANDOM_PREMIUM_CHEST_REWARD.ENERGY.arguments['energy'])
self.assertEqual(RandomPremiumRequestPrototype._db_count(), 1)
示例13: LongTeleportTests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class LongTeleportTests(CardsTestMixin, testcase.TestCase):
CARD = effects.LongTeleport
def setUp(self):
super(LongTeleportTests, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
result, account_1_id, bundle_id = register_user("test_user", "[email protected]", "111111")
self.account_1 = AccountPrototype.get_by_id(account_1_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account_1)
self.hero = self.storage.accounts_to_heroes[self.account_1.id]
self.hero.position.set_place(self.place_1)
self.card = self.CARD()
@mock.patch("the_tale.game.heroes.objects.Hero.is_battle_start_needed", lambda self: False)
def test_moving(self):
self.assertFalse(self.hero.actions.current_action.TYPE.is_MOVE_TO)
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ())
)
@mock.patch("the_tale.game.heroes.objects.Hero.is_battle_start_needed", lambda self: False)
def test_use(self):
actions_prototypes.ActionMoveToPrototype.create(hero=self.hero, destination=self.place_3)
self.storage.process_turn(continue_steps_if_needed=False)
self.assertTrue(self.hero.actions.current_action.state == actions_prototypes.ActionMoveToPrototype.STATE.MOVING)
self.assertTrue(self.hero.position.percents < 1)
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ())
)
self.assertTrue(self.hero.position.place.id, self.place_3.id)
@mock.patch("the_tale.game.heroes.objects.Hero.is_battle_start_needed", lambda self: False)
def test_use__wrong_state(self):
actions_prototypes.ActionMoveToPrototype.create(hero=self.hero, destination=self.place_3)
self.assertTrue(self.hero.actions.current_action.state != actions_prototypes.ActionMoveToPrototype.STATE.MOVING)
with self.check_not_changed(lambda: self.hero.actions.current_action.percents):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual(
(result, step, postsave_actions), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ())
)
self.assertTrue(self.hero.position.place.id, self.place_1.id)
示例14: InPlaceActionCompanionDrinkArtifactTests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class InPlaceActionCompanionDrinkArtifactTests(testcase.TestCase):
def setUp(self):
super(InPlaceActionCompanionDrinkArtifactTests, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
self.account = self.accounts_factory.create_account()
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.action_idl = self.hero.actions.current_action
self.companion_record = companions_logic.create_random_companion_record('thief', state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(self.companion_record))
self.hero.money = f.expected_gold_in_day(self.hero.level)
self.hero.position.set_place(self.place_1)
self.hero.position.update_previous_place()
self.hero.position.set_place(self.place_2)
self.artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.loot, 1, rarity=RARITY.NORMAL)
self.hero.put_loot(self.artifact)
self.assertEqual(self.hero.bag.occupation, 1)
self.hero.position.move_out_place()
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: True)
def test_dring_artifact(self):
with self.check_decreased(lambda: self.hero.bag.occupation):
prototypes.ActionInPlacePrototype.create(hero=self.hero)
self.assertTrue(self.hero.journal.messages[-1].key.is_ACTION_INPLACE_COMPANION_DRINK_ARTIFACT)
def check_not_used(self):
with self.check_not_changed(lambda: self.hero.bag.occupation):
prototypes.ActionInPlacePrototype.create(hero=self.hero)
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: True)
def test_previouse_place_is_equal(self):
self.hero.position.update_previous_place()
self.check_not_used()
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: True)
def test_no_items(self):
self.hero.pop_loot(self.artifact)
self.check_not_used()
@mock.patch('the_tale.game.heroes.objects.Hero.can_companion_drink_artifact', lambda hero: False)
def test_companion_does_not_eat(self):
self.check_not_used()
示例15: ChangeHeroTest
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import load_account_data [as 别名]
class ChangeHeroTest(TestCase):
def setUp(self):
super(ChangeHeroTest, self).setUp()
place_1, place_2, place_3 = create_test_map()
result, account_id, bundle_id = register_user("test_user", "[email protected]", "111111")
self.account = AccountPrototype.get_by_id(account_id)
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.hero = self.storage.accounts_to_heroes[account_id]
self.hero.utg_name.properties = self.hero.utg_name.properties.clone(self.hero.gender.utg_id)
self.noun = names.generator.get_test_name(name="test_name", gender=GENDER.NEUTER)
self.race = RACE.ELF if RACE.ELF != self.hero.race else RACE.HUMAN
self.gender = GENDER.NEUTER if not self.hero.gender.is_NEUTER else GENDER.FEMININE
def tearDown(self):
pass
def test_create(self):
task = ChangeHeroTask(self.hero.id, name=self.noun, race=self.race, gender=self.gender)
self.assertEqual(task.state, CHANGE_HERO_TASK_STATE.UNPROCESSED)
self.assertEqual(self.hero.preferences.place, None)
self.assertEqual(task.name, self.noun)
self.assertEqual(task.race, self.race)
self.assertEqual(task.gender, self.gender)
def test_serialization(self):
task = ChangeHeroTask(self.hero.id, name=self.noun, race=self.race, gender=self.gender)
self.assertEqual(task.serialize(), ChangeHeroTask.deserialize(task.serialize()).serialize())
def test_check_change(self):
task = ChangeHeroTask(self.hero.id, name=self.noun, race=self.race, gender=self.gender)
self.assertNotEqual(self.hero.utg_name, self.noun)
self.assertNotEqual(self.hero.gender, self.gender)
self.assertNotEqual(self.hero.race, self.race)
self.assertFalse(self.hero.settings_approved)
with mock.patch("the_tale.game.heroes.objects.Hero.reset_accessors_cache") as reset_accessors_cache:
self.assertEqual(
task.process(FakePostpondTaskPrototype(), self.storage), POSTPONED_TASK_LOGIC_RESULT.SUCCESS
)
self.assertEqual(reset_accessors_cache.call_count, 1)
self.assertEqual(task.state, CHANGE_HERO_TASK_STATE.PROCESSED)
self.assertEqual(self.hero.utg_name.forms, self.noun.forms)
self.assertEqual(self.hero.utg_name.properties.get(utg_relations.GENDER), self.gender.utg_id)
self.assertEqual(self.hero.name, self.noun.normal_form())
self.assertEqual(self.hero.race, self.race)
self.assertEqual(self.hero.gender, self.gender)
self.assertTrue(self.hero.settings_approved)