Example #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')
    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)
Example #3
0
    def setUp(self):
        super(RepairBuildingTests, self).setUp()

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

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account(is_fast=True)

        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)
Example #4
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)
Example #5
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)
    def setUp(self):
        super(RepairBuildingTests, self).setUp()

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

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account(is_fast=True)

        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)
    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')
Example #8
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')
Example #9
0
    def setUp(self):
        super(UseCardTaskTests, 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.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
        }
Example #10
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
        }
Example #11
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())
Example #12
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)
Example #13
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()
Example #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()
    def setUp(self):
        super(BuildingRepairTest, self).setUp()

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

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account(is_fast=True)

        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()
Example #16
0
    def setUp(self):
        super(BuildingRepairTest, self).setUp()

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

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account(is_fast=True)

        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()
Example #17
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)
Example #18
0
    def test_duplicate_apply(self):
        self.assertEqual(Building.objects.all().count(), 0)

        VotePrototype.create(self.account2, self.bill,
                             relations.VOTE_TYPE.AGAINST)
        VotePrototype.create(self.account3, self.bill, relations.VOTE_TYPE.FOR)

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

        data = self.bill.user_form_initials
        data.update(linguistics_helpers.get_word_post_data(noun,
                                                           prefix='name'))
        data['approved'] = True
        form = self.bill.data.get_moderator_form_update(data)

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

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

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

        data = bill.user_form_initials
        data.update(
            linguistics_helpers.get_word_post_data(dup_noun, prefix='name'))
        data['approved'] = True
        form = bill.data.get_moderator_form_update(data)

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

        # apply first bill
        self.assertTrue(self.bill.apply())

        # apply second bill
        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)
Example #19
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())
Example #20
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,
             ()))
Example #21
0
    def test_duplicate_apply(self):
        self.assertEqual(Building.objects.all().count(), 0)

        VotePrototype.create(self.account2, self.bill, relations.VOTE_TYPE.AGAINST)
        VotePrototype.create(self.account3, self.bill, relations.VOTE_TYPE.FOR)

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

        data = self.bill.user_form_initials
        data.update(linguistics_helpers.get_word_post_data(noun, prefix='name'))
        data['approved'] = True
        form = self.bill.data.get_moderator_form_update(data)

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

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

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

        data = bill.user_form_initials
        data.update(linguistics_helpers.get_word_post_data(dup_noun, prefix='name'))
        data['approved'] = True
        form = bill.data.get_moderator_form_update(data)

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

        # apply first bill
        self.assertTrue(self.bill.apply())

        # apply second bill
        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)
Example #22
0
    def setUp(self):
        super(CardsRequestsTestsBase, 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.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'))
Example #23
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(hero_id=666,
                                         has_place_in_preferences=False,
                                         has_person_in_preferences=False,
                                         power=100)

        self.assertEqual(
            change_person_power_call.call_args,
            mock.call(hero_id=666,
                      has_place_in_preferences=False,
                      has_person_in_preferences=False,
                      person_id=self.person.id,
                      power_delta=100,
                      place_id=None))

        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(hero_id=666,
                                         has_place_in_preferences=False,
                                         has_person_in_preferences=False,
                                         power=-100)

        self.assertEqual(
            change_person_power_call.call_args,
            mock.call(hero_id=666,
                      has_place_in_preferences=False,
                      has_person_in_preferences=False,
                      person_id=self.person.id,
                      power_delta=-100,
                      place_id=None))
    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')
Example #25
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(hero_id=666, has_place_in_preferences=False, has_person_in_preferences=False, power=100)

        self.assertEqual(change_person_power_call.call_args, mock.call(hero_id=666,
                                                                       has_place_in_preferences=False,
                                                                       has_person_in_preferences=False,
                                                                       person_id=self.person.id,
                                                                       power_delta=100,
                                                                       place_id=None))

        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(hero_id=666, has_place_in_preferences=False, has_person_in_preferences=False, power=-100)

        self.assertEqual(change_person_power_call.call_args, mock.call(hero_id=666,
                                                                       has_place_in_preferences=False,
                                                                       has_person_in_preferences=False,
                                                                       person_id=self.person.id,
                                                                       power_delta=-100,
                                                                       place_id=None))
Example #26
0
    def setUp(self):
        super(CardsRequestsTestsBase, 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.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")
        )
Example #27
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")
        )
Example #28
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())
Example #29
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'))
Example #30
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())
Example #31
0
    def setUp(self):
        super(UseCardTaskTests, 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.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}
Example #32
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}
Example #33
0
 def apply(self, bill=None):
     if self.has_meaning():
         BuildingPrototype.create(self.person, utg_name=self.building_name_forms)
Example #34
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)
Example #35
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, ()))
Example #36
0
 def apply(self, bill=None):
     if self.has_meaning():
         BuildingPrototype.create(self.person,
                                  utg_name=self.building_name_forms)