Example #1
0
    def test_return_child_gifts(self):
        not_child_gift, child_gift, removed_artifact = artifacts_storage.all(
        )[:3]

        child_gift.special_effect = artifacts_relations.ARTIFACT_EFFECT.CHILD_GIFT
        removed_artifact.rare_effect = artifacts_relations.ARTIFACT_EFFECT.HEALTH

        self.hero.bag.put_artifact(
            not_child_gift.create_artifact(level=1, power=0))
        self.hero.bag.put_artifact(
            not_child_gift.create_artifact(level=1, power=0))
        self.hero.bag.put_artifact(
            not_child_gift.create_artifact(level=1, power=0))

        self.hero.bag.put_artifact(child_gift.create_artifact(level=1,
                                                              power=0))
        self.hero.bag.put_artifact(child_gift.create_artifact(level=1,
                                                              power=0))

        self.hero.bag.put_artifact(
            removed_artifact.create_artifact(level=1, power=0))
        self.hero.bag.put_artifact(
            removed_artifact.create_artifact(
                level=1, power=0, rarity=artifacts_relations.RARITY.RARE))

        with self.check_delta(lambda: self.hero.statistics.gifts_returned, 2):
            with self.check_delta(lambda: self.hero.bag.occupation, -3):
                self.ability.use(**self.use_attributes)
Example #2
0
 def test_load_data(self):
     self.assertEqual(len(artifacts_storage.all()), 11) # see create_test_map
     self.assertFalse(artifacts_storage.has_artifact('wrong_id'))
     self.assertTrue(artifacts_storage.has_artifact('loot_1'))
     self.assertTrue(artifacts_storage.has_artifact('loot_2'))
     self.assertTrue(artifacts_storage.has_artifact('loot_3'))
     self.assertTrue(artifacts_storage.has_artifact('helmet_1'))
     self.assertTrue(artifacts_storage.has_artifact('plate_1'))
     self.assertTrue(artifacts_storage.has_artifact('boots_1'))
Example #3
0
 def test_load_data(self):
     self.assertEqual(len(artifacts_storage.all()), 11)  # see create_test_map
     self.assertFalse(artifacts_storage.has_artifact("wrong_id"))
     self.assertTrue(artifacts_storage.has_artifact("loot_1"))
     self.assertTrue(artifacts_storage.has_artifact("loot_2"))
     self.assertTrue(artifacts_storage.has_artifact("loot_3"))
     self.assertTrue(artifacts_storage.has_artifact("helmet_1"))
     self.assertTrue(artifacts_storage.has_artifact("plate_1"))
     self.assertTrue(artifacts_storage.has_artifact("boots_1"))
Example #4
0
 def test_load_data(self):
     self.assertEqual(len(artifacts_storage.all()),
                      11)  # see create_test_map
     self.assertFalse(artifacts_storage.has_artifact('wrong_id'))
     self.assertTrue(artifacts_storage.has_artifact('loot_1'))
     self.assertTrue(artifacts_storage.has_artifact('loot_2'))
     self.assertTrue(artifacts_storage.has_artifact('loot_3'))
     self.assertTrue(artifacts_storage.has_artifact('helmet_1'))
     self.assertTrue(artifacts_storage.has_artifact('plate_1'))
     self.assertTrue(artifacts_storage.has_artifact('boots_1'))
Example #5
0
    def setUp(self):
        super(PrototypeTests, self).setUp()
        create_test_map()

        account = self.accounts_factory.create_account()
        self.hero = heroes_logic.load_hero(account_id=account.id)

        artifacts_storage.sync(force=True)

        self.artifact_record = artifacts_storage.all()[0]
Example #6
0
    def setUp(self):
        super(PrototypeTests, self).setUp()
        create_test_map()

        account = self.accounts_factory.create_account()
        self.hero = heroes_logic.load_hero(account_id=account.id)

        artifacts_storage.sync(force=True)

        self.artifact_record = artifacts_storage.all()[0]
Example #7
0
    def setUp(self):
        super(PrototypeTests, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user')
        self.hero = HeroPrototype.get_by_account_id(account_id)

        artifacts_storage.sync(force=True)

        self.artifact_record = artifacts_storage.all()[0]
Example #8
0
    def setUp(self):
        super(PrototypeTests, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user')
        self.hero = HeroPrototype.get_by_account_id(account_id)

        artifacts_storage.sync(force=True)

        self.artifact_record = artifacts_storage.all()[0]
Example #9
0
    def test_deserialization_of_disabled_artifact(self):
        artifact_record = artifacts_storage.all()[0]
        artifact = artifact_record.create_artifact(level=7, power=Power(1, 1))

        data = artifact.serialize()

        artifact_record.state = relations.ARTIFACT_RECORD_STATE.DISABLED
        artifact_record.save()

        artifact_2 = ArtifactPrototype.deserialize(data)

        self.assertNotEqual(artifact.id, artifact_2.id)
Example #10
0
    def test_deserialization_of_disabled_artifact(self):
        artifact_record = artifacts_storage.all()[0]
        artifact = artifact_record.create_artifact(level=7, power=Power(1, 1))

        data = artifact.serialize()

        artifact_record.state = relations.ARTIFACT_RECORD_STATE.DISABLED
        artifact_record.save()

        artifact_2 = ArtifactPrototype.deserialize(data)

        self.assertNotEqual(artifact.id, artifact_2.id)
Example #11
0
    def test_return_child_gifts(self):
        not_child_gift, child_gift, removed_artifact = artifacts_storage.all()[:3]

        child_gift.special_effect = artifacts_relations.ARTIFACT_EFFECT.CHILD_GIFT
        removed_artifact.rare_effect = artifacts_relations.ARTIFACT_EFFECT.HEALTH

        self.hero.bag.put_artifact(not_child_gift.create_artifact(level=1, power=0))
        self.hero.bag.put_artifact(not_child_gift.create_artifact(level=1, power=0))
        self.hero.bag.put_artifact(not_child_gift.create_artifact(level=1, power=0))

        self.hero.bag.put_artifact(child_gift.create_artifact(level=1, power=0))
        self.hero.bag.put_artifact(child_gift.create_artifact(level=1, power=0))

        self.hero.bag.put_artifact(removed_artifact.create_artifact(level=1, power=0))
        self.hero.bag.put_artifact(removed_artifact.create_artifact(level=1, power=0, rarity=artifacts_relations.RARITY.RARE))

        with self.check_delta(lambda: self.hero.statistics.gifts_returned, 2):
            with self.check_delta(lambda: self.hero.bag.occupation, -3):
                self.ability.use(**self.use_attributes)
Example #12
0
 def test_serialization(self):
     artifact = artifacts_storage.all()[0].create_artifact(level=6,
                                                           power=Power(
                                                               1, 100))
     self.assertEqual(artifact,
                      ArtifactPrototype.deserialize(artifact.serialize()))
Example #13
0
 def test_serialization(self):
     artifact = artifacts_storage.all()[0].create_artifact(level=6, power=Power(1, 100))
     self.assertEqual(artifact, ArtifactPrototype.deserialize(artifact.serialize()))