예제 #1
0
    def setUp(self):
        super(BuildingRenamingTests, self).setUp()

        self.person_1 = self.place1.persons[0]
        self.person_2 = self.place2.persons[0]
        self.person_3 = self.place3.persons[0]

        self.building = BuildingPrototype.create(
            self.person_1,
            utg_name=names.generator.get_test_name('building-name'))
        self.building_2 = BuildingPrototype.create(
            self.person_2,
            utg_name=names.generator.get_test_name('building-name-2'))

        self.bill_data = BuildingRenaming(
            person_id=self.person_1.id,
            old_place_name_forms=self.place1.utg_name,
            new_building_name_forms=names.generator.get_test_name(
                'new-building-name'))
        self.bill = BillPrototype.create(
            self.account1,
            'bill-caption',
            'bill-rationale',
            self.bill_data,
            chronicle_on_accepted='chronicle-accepted-1')
예제 #2
0
    def test_duplicate_apply(self):
        self.assertEqual(Building.objects.all().count(), 0)

        VotePrototype.create(self.account2, self.bill, False)
        VotePrototype.create(self.account3, self.bill, True)

        noun = names.generator.get_test_name('building-name')
        data = linguistics_helpers.get_word_post_data(noun, prefix='name')
        data.update({'approved': True})

        form = BuildingCreate.ModeratorForm(data)

        self.assertTrue(form.is_valid())
        self.bill.update_by_moderator(form)
        self.assertTrue(self.bill.apply())

        dup_noun = names.generator.get_test_name('dup-building-name')
        data = linguistics_helpers.get_word_post_data(dup_noun, prefix='name')
        data.update({'approved': True})

        form = BuildingCreate.ModeratorForm(data)

        bill = BillPrototype.get_by_id(self.bill.id)
        bill.state = BILL_STATE.VOTING
        bill.save()

        self.assertTrue(form.is_valid())
        bill.update_by_moderator(form)

        self.assertTrue(bill.apply())

        self.assertEqual(Building.objects.all().count(), 1)
        self.assertEqual(BuildingPrototype._db_get_object(0).utg_name, noun)
        self.assertNotEqual(
            BuildingPrototype._db_get_object(0).utg_name, dup_noun)
예제 #3
0
    def setUp(self):
        super(RepairBuildingTests, self).setUp()
        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_1_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        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 = self.storage.accounts_to_heroes[self.account_1.id]

        self.card = self.CARD()

        environment.deinitialize()
        environment.initialize()

        self.highlevel = environment.workers.highlevel
        self.highlevel.process_initialize(0, 'highlevel')

        self.building_1 = BuildingPrototype.create(person=self.place_1.persons[0], utg_name=names.generator.get_test_name('building-1-name'))
        self.building_2 = BuildingPrototype.create(person=self.place_2.persons[0], utg_name=names.generator.get_test_name('building-1-name'))

        self.building_1.amortize(c.TURNS_IN_HOUR*24)
        self.building_2.amortize(c.TURNS_IN_HOUR*24)
예제 #4
0
    def setUp(self):
        super(RepairBuildingTests, self).setUp()
        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_1_id, bundle_id = register_user(
            'test_user', '*****@*****.**', '111111')
        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 = self.storage.accounts_to_heroes[self.account_1.id]

        self.card = self.CARD()

        environment.deinitialize()
        environment.initialize()

        self.highlevel = environment.workers.highlevel
        self.highlevel.process_initialize(0, 'highlevel')

        self.building_1 = BuildingPrototype.create(
            person=self.place_1.persons[0],
            utg_name=names.generator.get_test_name('building-1-name'))
        self.building_2 = BuildingPrototype.create(
            person=self.place_2.persons[0],
            utg_name=names.generator.get_test_name('building-1-name'))

        self.building_1.amortize(c.TURNS_IN_HOUR * 24)
        self.building_2.amortize(c.TURNS_IN_HOUR * 24)
예제 #5
0
    def test_power_from_building(self):

        with mock.patch(
                'the_tale.game.workers.highlevel.Worker.cmd_change_power'
        ) as change_person_power_call:
            self.person.cmd_change_power(100, 1, 2)

        self.assertEqual(
            change_person_power_call.call_args,
            mock.call(person_id=self.person.id,
                      power_delta=100,
                      place_id=None,
                      positive_bonus=1,
                      negative_bonus=2))

        BuildingPrototype.create(
            self.person,
            utg_name=names.generator.get_test_name('building-name'))

        with mock.patch(
                'the_tale.game.workers.highlevel.Worker.cmd_change_power'
        ) as change_person_power_call:
            self.person.cmd_change_power(100, -2, -1)

        self.assertEqual(
            change_person_power_call.call_args,
            mock.call(person_id=self.person.id,
                      power_delta=100,
                      place_id=None,
                      positive_bonus=-2,
                      negative_bonus=-1))
예제 #6
0
    def test_sync_data__power_from_building(self):
        from the_tale.game.map.places.prototypes import BuildingPrototype

        person_1 = self.p1.persons[0]

        BuildingPrototype.create(person_1, utg_name=names.generator.get_test_name(u'noun'))

        self.assertEqual(self.p1.power, 0)
        self.assertEqual(person_1.power, 0)

        self.worker.process_change_power(person_id=person_1.id, power_delta=1000, place_id=None, positive_bonus=0, negative_bonus=0)

        self.worker.sync_data()

        place_power = self.p1.power
        person_power = person_1.power

        self.assertTrue(place_power > 1000)
        self.assertTrue(person_power > 1000)

        self.worker.process_change_power(place_id=self.p1.id, power_delta=-10, person_id=None, positive_bonus=0, negative_bonus=0)

        self.worker.sync_data()

        self.assertEqual(self.p1.power, place_power - 10)
        self.assertEqual(person_1.power, person_power)
예제 #7
0
    def test_duplicate_apply(self):
        self.assertEqual(Building.objects.all().count(), 0)

        VotePrototype.create(self.account2, self.bill, False)
        VotePrototype.create(self.account3, self.bill, True)

        noun = names.generator.get_test_name('building-name')
        data = linguistics_helpers.get_word_post_data(noun, prefix='name')
        data.update({'approved': True})

        form = BuildingCreate.ModeratorForm(data)

        self.assertTrue(form.is_valid())
        self.bill.update_by_moderator(form)
        self.assertTrue(self.bill.apply())

        dup_noun = names.generator.get_test_name('dup-building-name')
        data = linguistics_helpers.get_word_post_data(dup_noun, prefix='name')
        data.update({'approved': True})

        form = BuildingCreate.ModeratorForm(data)

        bill = BillPrototype.get_by_id(self.bill.id)
        bill.state = BILL_STATE.VOTING
        bill.save()

        self.assertTrue(form.is_valid())
        bill.update_by_moderator(form)

        self.assertTrue(bill.apply())

        self.assertEqual(Building.objects.all().count(), 1)
        self.assertEqual(BuildingPrototype._db_get_object(0).utg_name, noun)
        self.assertNotEqual(BuildingPrototype._db_get_object(0).utg_name, dup_noun)
예제 #8
0
    def test_dynamic_position_radius(self):
        with mock.patch('the_tale.game.map.places.conf.places_settings.BUILDING_POSITION_RADIUS', 2):
            positions = BuildingPrototype.get_available_positions(-3, -1)
            self.assertEqual(positions, set([(0, 0), (0, 1), (0, 2)]))

        with mock.patch('the_tale.game.map.places.conf.places_settings.BUILDING_POSITION_RADIUS', 2):
            positions = BuildingPrototype.get_available_positions(-4, -1)
            self.assertEqual(positions, set([(0, 0), (0, 1), (0, 2), (0, 3)]))
예제 #9
0
    def test_dynamic_position_radius(self):
        with mock.patch(
                'the_tale.game.map.places.conf.places_settings.BUILDING_POSITION_RADIUS',
                2):
            positions = BuildingPrototype.get_available_positions(-3, -1)
            self.assertEqual(positions, set([(0, 0), (0, 1), (0, 2)]))

        with mock.patch(
                'the_tale.game.map.places.conf.places_settings.BUILDING_POSITION_RADIUS',
                2):
            positions = BuildingPrototype.get_available_positions(-4, -1)
            self.assertEqual(positions, set([(0, 0), (0, 1), (0, 2), (0, 3)]))
예제 #10
0
    def setUp(self):
        super(BuildingDestroyTests, self).setUp()

        self.person_1 = self.place1.persons[0]
        self.person_2 = self.place2.persons[0]
        self.person_3 = self.place3.persons[0]

        self.building_1 = BuildingPrototype.create(self.person_1, utg_name=names.generator.get_test_name('building-name-1'))
        self.building_2 = BuildingPrototype.create(self.person_2, utg_name=names.generator.get_test_name('building-name-2'))

        self.bill_data = BuildingDestroy(person_id=self.person_1.id, old_place_name_forms=self.place1.utg_name)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #11
0
    def test_power_from_building(self):

        with mock.patch('the_tale.game.workers.highlevel.Worker.cmd_change_power') as change_person_power_call:
            self.person.cmd_change_power(100, 1, 2)

        self.assertEqual(change_person_power_call.call_args, mock.call(person_id=self.person.id, power_delta=100, place_id=None, positive_bonus=1, negative_bonus=2))

        BuildingPrototype.create(self.person, utg_name=names.generator.get_test_name('building-name'))

        with mock.patch('the_tale.game.workers.highlevel.Worker.cmd_change_power') as change_person_power_call:
            self.person.cmd_change_power(100, -2, -1)

        self.assertEqual(change_person_power_call.call_args, mock.call(person_id=self.person.id, power_delta=100, place_id=None, positive_bonus=-2, negative_bonus=-1))
예제 #12
0
    def test_amortization_grows(self):
        building = BuildingPrototype.create(self.place_1.persons[0], utg_name=names.generator.get_test_name(name='building-name'))

        old_integrity = building.integrity
        building.amortize(1000)
        amortization_delta = old_integrity - building.integrity

        building_2 = BuildingPrototype.create(self.place_1.persons[1], utg_name=names.generator.get_test_name(name='building-name-2'))

        old_integrity_2 = building_2.integrity
        building_2.amortize(1000)
        amortization_delta_2 = old_integrity_2 - building_2.integrity

        self.assertTrue(amortization_delta < amortization_delta_2)
예제 #13
0
 def test_move_out_game_with_building(self):
     building = BuildingPrototype.create(
         self.person,
         utg_name=names.generator.get_test_name('building-name'))
     self.assertTrue(building.state.is_WORKING)
     self.person.move_out_game()
     self.assertTrue(building.state.is_DESTROYED)
예제 #14
0
    def setUp(self):
        super(BuildingRepairTest, self).setUp()
        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_1_id, bundle_id = register_user(
            'test_user', '*****@*****.**', '111111')
        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]

        self.ability_1 = self.PROCESSOR()
        self.ability_2 = self.PROCESSOR()

        environment.deinitialize()
        environment.initialize()

        self.highlevel = environment.workers.highlevel
        self.highlevel.process_initialize(0, 'highlevel')

        self.building = BuildingPrototype.create(
            self.place_1.persons[0],
            utg_name=names.generator.get_test_name('building-name'))
        self.building._model.integrity = 0.5
        self.building.save()
예제 #15
0
    def setUp(self):
        super(UseCardTaskTests, self).setUp()

        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_id, bundle_id = register_user("test_user_1", "*****@*****.**", "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[self.account.id]

        self.building_1 = BuildingPrototype.create(
            person=self.place_1.persons[0], utg_name=names.generator.get_test_name("building-1-name")
        )

        environment.deinitialize()
        environment.initialize()

        self.highlevel = environment.workers.highlevel
        self.highlevel.process_initialize(0, "highlevel")

        self.task_data = {
            "place_id": self.place_1.id,
            "person_id": self.place_1.persons[0].id,
            "building_id": self.building_1.id,
        }
예제 #16
0
    def test_destroy__update_storage(self):
        building = BuildingPrototype.create(self.place_1.persons[0], utg_name=names.generator.get_test_name(name='building-name'))

        old_version = buildings_storage.version
        building.destroy()
        self.assertNotEqual(old_version, buildings_storage.version)
        self.assertFalse(building.id in buildings_storage)
예제 #17
0
    def test_user_form_choices(self):

        BuildingPrototype.create(self.place2.persons[0], utg_name=names.generator.get_test_name('r-building-name'))

        form = self.bill.data.get_user_form_update(initial={'person': self.bill.data.person_id })

        persons_ids = []

        for city_name, person_choices in form.fields['person'].choices:
            persons_ids.extend(choice_id for choice_id, choice_name in person_choices)

        self.assertTrue(self.bill.data.person_id in persons_ids)

        self.check_persons_from_place_in_choices(self.place1, persons_ids)
        self.check_persons_from_place_in_choices(self.place2, persons_ids)
        self.check_persons_from_place_in_choices(self.place3, persons_ids)
예제 #18
0
    def setUp(self):
        super(BuildingRepairTest, self).setUp()
        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_1_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        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]

        self.ability_1 = self.PROCESSOR()
        self.ability_2 = self.PROCESSOR()

        environment.deinitialize()
        environment.initialize()

        self.highlevel = environment.workers.highlevel
        self.highlevel.process_initialize(0, 'highlevel')

        self.building = BuildingPrototype.create(self.place_1.persons[0], utg_name=names.generator.get_test_name('building-name'))
        self.building._model.integrity = 0.5
        self.building.save()
예제 #19
0
    def test_building_power_point(self):
        building = BuildingPrototype.create(
            self.place_1.persons[0],
            utg_name=names.generator.get_test_name('building-name'))
        building._model.type = building_type
        building.save()

        self.assertTrue(len(get_building_power_points(building)) > 0)
예제 #20
0
 def test_building(self):
     building = BuildingPrototype.create(
         self.place_1.persons[0], utg_name=names.generator.get_test_name("building-name")
     )
     texts = [building.type.text, jinja2.escape(building.person.name), jinja2.escape(self.place_1.name)]
     self.check_html_ok(
         self.request_html(reverse("game:map:cell-info") + ("?x=%d&y=%d" % (building.x, building.y))), texts=texts
     )
예제 #21
0
    def test_save__update_storage(self):
        building = BuildingPrototype.create(
            self.place_1.persons[0],
            utg_name=names.generator.get_test_name(name='building-name'))

        old_version = buildings_storage.version
        building.save()
        self.assertNotEqual(old_version, buildings_storage.version)
예제 #22
0
    def test_create_after_destroy(self):
        self.assertEqual(Building.objects.all().count(), 0)

        old_version = buildings_storage.version

        person = self.place_1.persons[0]

        name = names.generator.get_test_name(name='building-name')
        building = BuildingPrototype.create(person, utg_name=name)
        building.destroy()

        name_2 = names.generator.get_test_name(name='building-name-2')
        building = BuildingPrototype.create(person, utg_name=name_2)

        self.assertNotEqual(old_version, buildings_storage.version)

        self.assertEqual(Building.objects.all().count(), 1)
        self.assertEqual(building.utg_name, name_2)
예제 #23
0
    def test_create_after_destroy(self):
        self.assertEqual(Building.objects.all().count(), 0)

        old_version = buildings_storage.version

        person = self.place_1.persons[0]

        name = names.generator.get_test_name(name='building-name')
        building = BuildingPrototype.create(person, utg_name=name)
        building.destroy()

        name_2 = names.generator.get_test_name(name='building-name-2')
        building = BuildingPrototype.create(person, utg_name=name_2)

        self.assertNotEqual(old_version, buildings_storage.version)

        self.assertEqual(Building.objects.all().count(), 1)
        self.assertEqual(building.utg_name, name_2)
예제 #24
0
    def test_get_available_positions(self):

        building = BuildingPrototype.create(self.place_1.persons[0],
                                            utg_name=names.generator.get_test_name(name='building-name'))

        positions = BuildingPrototype.get_available_positions(self.place_1.x, self.place_1.y)

        self.assertTrue(positions)

        for place in places_storage.all():
            self.assertFalse((place.x, place.y) in positions)

        for building in buildings_storage.all():
            self.assertFalse((building.x, building.y) in positions)

        for x, y in positions:
            self.assertTrue(0 <= x < map_settings.WIDTH)
            self.assertTrue(0 <= y < map_settings.HEIGHT)
예제 #25
0
    def test_amortization_grows(self):
        building = BuildingPrototype.create(
            self.place_1.persons[0],
            utg_name=names.generator.get_test_name(name='building-name'))

        old_integrity = building.integrity
        building.amortize(1000)
        amortization_delta = old_integrity - building.integrity

        building_2 = BuildingPrototype.create(
            self.place_1.persons[1],
            utg_name=names.generator.get_test_name(name='building-name-2'))

        old_integrity_2 = building_2.integrity
        building_2.amortize(1000)
        amortization_delta_2 = old_integrity_2 - building_2.integrity

        self.assertTrue(amortization_delta < amortization_delta_2)
예제 #26
0
    def test_get_available_positions(self):

        building = BuildingPrototype.create(
            self.place_1.persons[0],
            utg_name=names.generator.get_test_name(name='building-name'))

        positions = BuildingPrototype.get_available_positions(
            self.place_1.x, self.place_1.y)

        self.assertTrue(positions)

        for place in places_storage.all():
            self.assertFalse((place.x, place.y) in positions)

        for building in buildings_storage.all():
            self.assertFalse((building.x, building.y) in positions)

        for x, y in positions:
            self.assertTrue(0 <= x < map_settings.WIDTH)
            self.assertTrue(0 <= y < map_settings.HEIGHT)
예제 #27
0
    def test_user_form_choices(self):

        BuildingPrototype.create(
            self.place2.persons[0],
            utg_name=names.generator.get_test_name('r-building-name'))

        form = self.bill.data.get_user_form_update(
            initial={'person': self.bill.data.person_id})

        persons_ids = []

        for city_name, person_choices in form.fields['person'].choices:
            persons_ids.extend(choice_id
                               for choice_id, choice_name in person_choices)

        self.assertTrue(self.bill.data.person_id in persons_ids)

        self.check_persons_from_place_in_choices(self.place1, persons_ids)
        self.check_persons_from_place_in_choices(self.place2, persons_ids)
        self.check_persons_from_place_in_choices(self.place3, persons_ids)
예제 #28
0
    def setUp(self):
        super(BillBuildingDestroyTests, self).setUp()

        self.person = self.place1.persons[0]
        self.building = BuildingPrototype.create(self.person, utg_name=names.generator.get_test_name('building-name'))

        bill_data = bills.BuildingDestroy(person_id=self.person.id, old_place_name_forms=self.place1.utg_name)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.form = bills.BuildingDestroy.ModeratorForm({'approved': True})
        self.assertTrue(self.form.is_valid())
예제 #29
0
    def test_use_for_repaired_building(self):
        self.building = BuildingPrototype.create(
            self.place_1.persons[0],
            utg_name=names.generator.get_test_name('building-name'))
        self.building._model.integrity = 1.0
        self.building.save()

        self.assertEqual(
            self.ability_1.use(
                **self.use_attributes(hero=self.hero_1, storage=self.storage)),
            (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR,
             ()))
예제 #30
0
 def test_building(self):
     building = BuildingPrototype.create(
         self.place_1.persons[0],
         utg_name=names.generator.get_test_name('building-name'))
     texts = [
         building.type.text,
         jinja2.escape(building.person.name),
         jinja2.escape(self.place_1.name)
     ]
     self.check_html_ok(self.request_html(
         reverse('game:map:cell-info') + ('?x=%d&y=%d' %
                                          (building.x, building.y))),
                        texts=texts)
예제 #31
0
    def test_create(self):
        self.assertEqual(Building.objects.all().count(), 0)

        old_version = buildings_storage.version

        name = names.generator.get_test_name(name='building-name')

        building = BuildingPrototype.create(self.place_1.persons[0], utg_name=name)

        self.assertNotEqual(old_version, buildings_storage.version)

        self.assertEqual(Building.objects.all().count(), 1)

        old_version = buildings_storage.version

        name_2 = names.generator.get_test_name(name='building-name-2')
        building_2 = BuildingPrototype.create(self.place_1.persons[0], utg_name=name_2)

        self.assertEqual(old_version, buildings_storage.version)
        self.assertEqual(Building.objects.all().count(), 1)
        self.assertEqual(hash(building), hash(building_2))
        self.assertEqual(building.utg_name, name)
예제 #32
0
    def setUp(self):
        super(CardsRequestsTestsBase, self).setUp()
        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '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[self.account.id]

        self.card = objects.Card(relations.CARD_TYPE.KEEPERS_GOODS_COMMON)

        self.building_1 = BuildingPrototype.create(person=self.place_1.persons[0], utg_name=names.generator.get_test_name('building-1-name'))
예제 #33
0
    def test_amortize(self):
        building = BuildingPrototype.create(self.place_1.persons[0], utg_name=names.generator.get_test_name(name='building-name'))

        old_integrity = building.integrity

        building.amortize(1000)

        self.assertTrue(old_integrity > building.integrity)

        building._model.integrity = -1

        building.amortize(1000)

        self.assertEqual(building.integrity, 0)
        self.assertTrue(building.state.is_WORKING)
예제 #34
0
    def test_create(self):
        self.assertEqual(Building.objects.all().count(), 0)

        old_version = buildings_storage.version

        name = names.generator.get_test_name(name='building-name')

        building = BuildingPrototype.create(self.place_1.persons[0],
                                            utg_name=name)

        self.assertNotEqual(old_version, buildings_storage.version)

        self.assertEqual(Building.objects.all().count(), 1)

        old_version = buildings_storage.version

        name_2 = names.generator.get_test_name(name='building-name-2')
        building_2 = BuildingPrototype.create(self.place_1.persons[0],
                                              utg_name=name_2)

        self.assertEqual(old_version, buildings_storage.version)
        self.assertEqual(Building.objects.all().count(), 1)
        self.assertEqual(hash(building), hash(building_2))
        self.assertEqual(building.utg_name, name)
예제 #35
0
    def test_mastery_from_building(self):

        while True:
            person = create_person(self.p1, PERSON_STATE.IN_GAME)
            old_mastery = person.mastery

            if old_mastery < 0.8:
                break

        building = BuildingPrototype.create(person, utg_name=names.generator.get_test_name('building-name'))

        max_mastery = person.mastery

        building._model.integrity = 0.5

        self.assertTrue(old_mastery < person.mastery < max_mastery)
예제 #36
0
    def test_amortize(self):
        building = BuildingPrototype.create(
            self.place_1.persons[0],
            utg_name=names.generator.get_test_name(name='building-name'))

        old_integrity = building.integrity

        building.amortize(1000)

        self.assertTrue(old_integrity > building.integrity)

        building._model.integrity = -1

        building.amortize(1000)

        self.assertEqual(building.integrity, 0)
        self.assertTrue(building.state.is_WORKING)
예제 #37
0
    def test_mastery_from_building(self):

        while True:
            person = create_person(self.p1, PERSON_STATE.IN_GAME)
            old_mastery = person.mastery

            if old_mastery < 0.8:
                break

        building = BuildingPrototype.create(
            person, utg_name=names.generator.get_test_name('building-name'))

        max_mastery = person.mastery

        building._model.integrity = 0.5

        self.assertTrue(old_mastery < person.mastery < max_mastery)
예제 #38
0
    def setUp(self):
        super(BillBuildingRenamingTests, self).setUp()

        self.person = self.place1.persons[0]
        self.building = BuildingPrototype.create(self.person, utg_name=names.generator.get_test_name('building-name'))

        bill_data = bills.BuildingRenaming(person_id=self.person.id,
                                           old_place_name_forms=self.place1.utg_name,
                                           new_building_name_forms=names.generator.get_test_name('new-building-name'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        data = linguistics_helpers.get_word_post_data(bill_data.new_building_name_forms, prefix='name')
        data.update({'approved': True})


        self.form = bills.BuildingRenaming.ModeratorForm(data)
        self.assertTrue(self.form.is_valid())
예제 #39
0
    def setUp(self):
        super(UseCardTaskTests, self).setUp()

        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '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[self.account.id]

        self.building_1 = BuildingPrototype.create(person=self.place_1.persons[0], utg_name=names.generator.get_test_name('building-1-name'))

        environment.deinitialize()
        environment.initialize()

        self.highlevel = environment.workers.highlevel
        self.highlevel.process_initialize(0, 'highlevel')


        self.task_data = {'place_id': self.place_1.id,
                          'person_id': self.place_1.persons[0].id,
                          'building_id': self.building_1.id}
예제 #40
0
    def apply(self, bill=None):
        if self.person is None or self.person.out_game:
            return

        BuildingPrototype.create(self.person, utg_name=self.building_name_forms)
예제 #41
0
 def apply(self, bill=None):
     if self.has_meaning():
         BuildingPrototype.create(self.person, utg_name=self.building_name_forms)
예제 #42
0
    def test_building_power_point(self):
        building = BuildingPrototype.create(self.place_1.persons[0], utg_name=names.generator.get_test_name('building-name'))
        building._model.type = building_type
        building.save()

        self.assertTrue(len(get_building_power_points(building)) > 0)
예제 #43
0
 def test_move_out_game_with_building(self):
     building = BuildingPrototype.create(self.person, utg_name=names.generator.get_test_name('building-name'))
     self.assertTrue(building.state.is_WORKING)
     self.person.move_out_game()
     self.assertTrue(building.state.is_DESTROYED)
예제 #44
0
 def apply(self, bill=None):
     if self.has_meaning():
         BuildingPrototype.create(self.person,
                                  utg_name=self.building_name_forms)
예제 #45
0
    def apply(self, bill=None):
        if self.person is None or self.person.out_game:
            return

        BuildingPrototype.create(self.person,
                                 utg_name=self.building_name_forms)
예제 #46
0
    def test_use_for_repaired_building(self):
        self.building = BuildingPrototype.create(self.place_1.persons[0], utg_name=names.generator.get_test_name('building-name'))
        self.building._model.integrity = 1.0
        self.building.save()

        self.assertEqual(self.ability_1.use(**self.use_attributes(hero=self.hero_1, storage=self.storage)), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ()))