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

        self.bill_data = PlaceDescripton(place_id=self.place1.id,
                                         description='description')
        self.bill_1 = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            'bill-1-rationale',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
        self.bill_2 = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            'bill-1-rationale',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
        self.bill_3 = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            'bill-1-rationale',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')

        BillPrototype._model_class.objects.all().update(
            updated_at=datetime.datetime.now() -
            datetime.timedelta(seconds=bills_settings.BILL_LIVE_TIME),
            approved_by_moderator=True)

        self.bill_1.reload()
        self.bill_2.reload()
        self.bill_3.reload()
예제 #2
0
    def create_bill_decline__exchange(self):
        resource_1, resource_2 = choose_exchange_resources()

        declined_bill_data = bills.PlaceResourceExchange(
            place_1_id=self.place_1.id,
            place_2_id=self.place_2.id,
            resource_1=resource_1,
            resource_2=resource_2)

        declined_bill = BillPrototype.create(
            self.account,
            'declined-bill-caption',
            'declined-bill-rationale',
            declined_bill_data,
            chronicle_on_accepted='chronicle-on-accepted')

        declined_data = declined_bill.user_form_initials
        declined_data['approved'] = True

        declined_form = bills.PlaceResourceExchange.ModeratorForm(
            declined_data)
        self.assertTrue(declined_form.is_valid())
        declined_bill.update_by_moderator(declined_form)
        declined_bill.apply()

        bill_data = bills.BillDecline(declined_bill_id=declined_bill.id)
        bill = BillPrototype.create(
            self.account,
            'bill-caption',
            'bill-rationale',
            bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
        return bill, declined_bill
예제 #3
0
    def setUp(self):
        super(BillDeclineResourceExchangeTests, self).setUp()

        self.resource_1, self.resource_2 = choose_exchange_resources()

        self.declined_bill_data = PlaceResourceExchange(
            place_1_id=self.place1.id,
            place_2_id=self.place2.id,
            resource_1=self.resource_1,
            resource_2=self.resource_2)

        self.declined_bill = BillPrototype.create(
            owner=self.account1,
            caption='declined-bill-caption',
            chronicle_on_accepted='chronicle-on-accepted',
            bill=self.declined_bill_data)

        data = self.declined_bill.user_form_initials
        data['approved'] = True
        declined_form = self.declined_bill.data.get_moderator_form_update(data)

        self.assertTrue(declined_form.is_valid())
        self.declined_bill.update_by_moderator(declined_form)
        self.declined_bill.apply()

        self.bill_data = BillDecline(declined_bill_id=self.declined_bill.id)
        self.bill = BillPrototype.create(
            self.account1,
            'bill-caption',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted',
        )
예제 #4
0
    def create_bill_decline__exchange(self):
        resource_1, resource_2 = choose_exchange_resources()

        declined_bill_data = bills.PlaceResourceExchange(
            place_1_id=self.place_1.id, place_2_id=self.place_2.id, resource_1=resource_1, resource_2=resource_2
        )

        declined_bill = BillPrototype.create(
            self.account,
            "declined-bill-caption",
            "declined-bill-rationale",
            declined_bill_data,
            chronicle_on_accepted="chronicle-on-accepted",
        )

        declined_form = bills.PlaceResourceExchange.ModeratorForm({"approved": True})
        self.assertTrue(declined_form.is_valid())
        declined_bill.update_by_moderator(declined_form)
        declined_bill.apply()

        bill_data = bills.BillDecline(declined_bill_id=declined_bill.id)
        bill = BillPrototype.create(
            self.account, "bill-caption", "bill-rationale", bill_data, chronicle_on_accepted="chronicle-on-accepted"
        )
        return bill, declined_bill
예제 #5
0
    def setUp(self):
        super(BillDeclineResourceExchangeTests, self).setUp()

        self.resource_1, self.resource_2 = choose_exchange_resources()

        self.declined_bill_data = PlaceResourceExchange(
            place_1_id=self.place1.id, place_2_id=self.place2.id, resource_1=self.resource_1, resource_2=self.resource_2
        )

        self.declined_bill = BillPrototype.create(
            owner=self.account1,
            caption="declined-bill-caption",
            rationale="declined-bill-rationale",
            chronicle_on_accepted="chronicle-on-accepted",
            bill=self.declined_bill_data,
        )

        data = self.declined_bill.user_form_initials
        data["approved"] = True
        declined_form = self.declined_bill.data.get_moderator_form_update(data)

        self.assertTrue(declined_form.is_valid())
        self.declined_bill.update_by_moderator(declined_form)
        self.declined_bill.apply()

        self.bill_data = BillDecline(declined_bill_id=self.declined_bill.id)
        self.bill = BillPrototype.create(
            self.account1,
            "bill-caption",
            "bill-rationale",
            self.bill_data,
            chronicle_on_accepted="chronicle-on-accepted",
        )
예제 #6
0
    def create_bill_decline__conversion(self):
        conversion_1, conversion_2 = choose_conversions()

        declined_bill_data = bills.PlaceResourceConversion(
            place_id=self.place_1.id, conversion=conversion_1)

        declined_bill = BillPrototype.create(
            self.account,
            'declined-bill-caption',
            'declined-bill-rationale',
            declined_bill_data,
            chronicle_on_accepted='chronicle-on-accepted')

        declined_data = declined_bill.user_form_initials
        declined_data['approved'] = True

        declined_form = bills.PlaceResourceConversion.ModeratorForm(
            declined_data)
        self.assertTrue(declined_form.is_valid())
        declined_bill.update_by_moderator(declined_form)
        declined_bill.apply()

        bill_data = bills.BillDecline(declined_bill_id=declined_bill.id)
        bill = BillPrototype.create(
            self.account,
            'bill-caption',
            'bill-rationale',
            bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
        return bill, declined_bill
예제 #7
0
    def setUp(self):
        super(GetApplicableBillsTest, self).setUp()

        self.bill_data = PlaceDescripton(place_id=self.place1.id, description='description')
        self.bill_1 = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
        self.bill_2 = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
        self.bill_3 = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')

        BillPrototype._model_class.objects.all().update(updated_at=datetime.datetime.now() - datetime.timedelta(seconds=bills_settings.BILL_LIVE_TIME),
                                                        approved_by_moderator=True)

        self.bill_1.reload()
        self.bill_2.reload()
        self.bill_3.reload()
예제 #8
0
    def test_update(self):
        declined_bill_2 = BillPrototype.create(
            self.account1,
            'declined-bill-caption',
            self.declined_bill_data,
            chronicle_on_accepted='chronicle-on-accepted-2')

        data = declined_bill_2.user_form_initials
        data['approved'] = True
        declined_form = declined_bill_2.data.get_moderator_form_update(data)

        self.assertTrue(declined_form.is_valid())
        declined_bill_2.update_by_moderator(declined_form)
        declined_bill_2.apply()

        form = self.bill.data.get_user_form_update(
            post={
                'caption': 'new-caption',
                'chronicle_on_accepted': 'chronicle-on-accepted-3',
                'declined_bill': declined_bill_2.id
            })
        self.assertTrue(form.is_valid())

        self.bill.update(form)

        self.bill = BillPrototype.get_by_id(self.bill.id)

        self.assertEqual(self.bill.data.declined_bill_id, declined_bill_2.id)
예제 #9
0
    def test_user_form_validation__wrong_bill(self):
        bill_data = PlaceDescripton(place_id=self.place1.id,
                                    description='new description')
        bill = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            bill_data,
            chronicle_on_accepted='chronicle-on-accepted',
        )

        data = bill.user_form_initials
        data['approved'] = True
        form = bill.data.get_moderator_form_update(data)

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

        form = self.bill.data.get_user_form_update(
            post={
                'caption': 'caption',
                'chronicle_on_accepted': 'chronicle-on-accepted-3',
                'declined_bill': bill.id
            })
        self.assertFalse(form.is_valid())
예제 #10
0
    def test_get_exchanges_for_bill_id__exists(self):
        from the_tale.forum.models import Category, SubCategory
        from the_tale.game.bills.conf import bills_settings
        from the_tale.game.bills import bills
        from the_tale.game.bills.prototypes import BillPrototype

        account = self.accounts_factory.create_account()

        forum_category = Category.objects.create(caption='category-1', slug='category-1')
        SubCategory.objects.create(caption=bills_settings.FORUM_CATEGORY_UID + '-caption',
                                   uid=bills_settings.FORUM_CATEGORY_UID,
                                   category=forum_category)

        bill_data = bills.PlaceRenaming(place_id=self.place_1.id, name_forms=names.generator().get_test_name('new_name'))
        bill = BillPrototype.create(account, 'bill-caption', 'bill-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        ResourceExchangePrototype.create(place_1=self.place_1,
                                         place_2=self.place_2,
                                         resource_1=self.resource_1,
                                         resource_2=self.resource_2,
                                         bill=None)

        exchange_2 = ResourceExchangePrototype.create(place_1=self.place_1,
                                                      place_2=self.place_3,
                                                      resource_1=self.resource_1,
                                                      resource_2=self.resource_2,
                                                      bill=bill)

        ResourceExchangePrototype.create(place_1=self.place_2,
                                         place_2=self.place_3,
                                         resource_1=self.resource_1,
                                         resource_2=self.resource_2,
                                         bill=None)

        self.assertEqual(exchange_2.id, storage.resource_exchanges.get_exchange_for_bill_id(bill.id).id)
예제 #11
0
    def test_update(self):
        declined_bill_2 = BillPrototype.create(
            self.account1,
            'declined-bill-caption',
            'declined-bill-rationale',
            self.declined_bill_data,
            chronicle_on_accepted='chronicle-on-accepted-2')
        declined_form = PlaceResourceExchange.ModeratorForm({'approved': True})
        self.assertTrue(declined_form.is_valid())
        declined_bill_2.update_by_moderator(declined_form)
        declined_bill_2.apply()

        form = self.bill.data.get_user_form_update(
            post={
                'caption': 'new-caption',
                'rationale': 'new-rationale',
                'chronicle_on_accepted': 'chronicle-on-accepted-3',
                'declined_bill': declined_bill_2.id
            })
        self.assertTrue(form.is_valid())

        self.bill.update(form)

        self.bill = BillPrototype.get_by_id(self.bill.id)

        self.assertEqual(self.bill.data.declined_bill_id, declined_bill_2.id)
예제 #12
0
    def setUp(self):
        super(PersonRemoveSocialConnectionTests, self).setUp()

        self.person_1_1 = self.place1.persons[0]
        self.person_2_1, self.person_2_2 = self.place2.persons[0:2]
        self.person_3_1 = self.place3.persons[0]

        self.account = self.accounts_factory.create_account()

        persons_logic.create_social_connection(
            connection_type=persons_relations.SOCIAL_CONNECTION_TYPE.PARTNER,
            person_1=self.person_1_1,
            person_2=self.person_2_1)

        self.bill_data = PersonRemoveSocialConnection(
            person_1_id=self.person_1_1.id, person_2_id=self.person_2_1.id)
        self.bill = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')

        self.person_1_1.politic_power.change_power(self.person_1_1,
                                                   hero_id=self.account.id,
                                                   has_in_preferences=True,
                                                   power=100)
예제 #13
0
    def test_user_form_validation__wrong_bill(self):
        bill_data = PlaceDescripton(place_id=self.place1.id, description="new description")
        bill = BillPrototype.create(
            self.account1,
            "bill-1-caption",
            "bill-1-rationale",
            bill_data,
            chronicle_on_accepted="chronicle-on-accepted",
        )

        data = bill.user_form_initials
        data["approved"] = True
        form = bill.data.get_moderator_form_update(data)

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

        form = self.bill.data.get_user_form_update(
            post={
                "caption": "caption",
                "rationale": "rationale",
                "chronicle_on_accepted": "chronicle-on-accepted-3",
                "declined_bill": bill.id,
            }
        )
        self.assertFalse(form.is_valid())
예제 #14
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())
예제 #15
0
    def setUp(self):
        super(RecordTests, self).setUp()
        self.place_1, self.place_2, self.place_3 = create_test_map()

        result, account_id, bundle_id = register_user('test_user',
                                                      '*****@*****.**',
                                                      '111111')
        self.account = AccountPrototype.get_by_id(account_id)

        forum_category = Category.objects.create(caption='category-1',
                                                 slug='category-1')
        SubCategory.objects.create(caption=bills_settings.FORUM_CATEGORY_UID +
                                   '-caption',
                                   uid=bills_settings.FORUM_CATEGORY_UID,
                                   category=forum_category)

        bill_data = bills.PlaceRenaming(
            place_id=self.place_1.id,
            name_forms=names.generator.get_test_name('new_name'))
        self.bill = BillPrototype.create(
            self.account,
            'bill-caption',
            'bill-rationale',
            bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
예제 #16
0
    def create_bill_decline__conversion(self):
        conversion_1, conversion_2 = choose_conversions()

        declined_bill_data = bills.PlaceResourceConversion(place_id=self.place_1.id,
                                                           conversion=conversion_1)

        declined_bill = BillPrototype.create(self.account, 'declined-bill-caption', 'declined-bill-rationale', declined_bill_data, chronicle_on_accepted='chronicle-on-accepted')

        declined_form = bills.PlaceResourceConversion.ModeratorForm({'approved': True})
        self.assertTrue(declined_form.is_valid())
        declined_bill.update_by_moderator(declined_form)
        declined_bill.apply()

        bill_data = bills.BillDecline(declined_bill_id=declined_bill.id)
        bill = BillPrototype.create(self.account, 'bill-caption', 'bill-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')
        return bill, declined_bill
예제 #17
0
    def setUp(self):
        super(PersonMoveTests, self).setUp()

        self.person_1, self.person_2, self.person_3 = self.place1.persons[0:3]

        self.account = self.accounts_factory.create_account()

        politic_power_logic.add_power_impacts(
            persons_logic.tt_power_impacts(
                person_inner_circle=True,
                place_inner_circle=True,
                actor_type=tt_api_impacts.OBJECT_TYPE.HERO,
                actor_id=self.account.id,
                person=self.person_1,
                amount=100,
                fame=0))

        politic_power_logic.add_power_impacts(
            persons_logic.tt_power_impacts(
                person_inner_circle=True,
                place_inner_circle=True,
                actor_type=tt_api_impacts.OBJECT_TYPE.HERO,
                actor_id=self.account.id,
                person=self.person_2,
                amount=100,
                fame=0))

        self.bill_data = PersonMove(person_id=self.person_1.id,
                                    new_place_id=self.place2.id)
        self.bill = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
    def setUp(self):
        super(PersonRemoveSocialConnectionTests, self).setUp()

        self.person_1_1 = self.place1.persons[0]
        self.person_2_1, self.person_2_2 = self.place2.persons[0:2]
        self.person_3_1 = self.place3.persons[0]

        self.account = self.accounts_factory.create_account()

        politic_power_logic.add_power_impacts(persons_logic.tt_power_impacts(person_inner_circle=True,
                                                                             place_inner_circle=True,
                                                                             actor_type=tt_api_impacts.OBJECT_TYPE.HERO,
                                                                             actor_id=self.account.id,
                                                                             person=self.person_1_1,
                                                                             amount=100,
                                                                             fame=0))
        politic_power_logic.add_power_impacts(persons_logic.tt_power_impacts(person_inner_circle=True,
                                                                             place_inner_circle=True,
                                                                             actor_type=tt_api_impacts.OBJECT_TYPE.HERO,
                                                                             actor_id=self.account.id,
                                                                             person=self.person_2_2,
                                                                             amount=100,
                                                                             fame=0))

        persons_logic.create_social_connection(connection_type=persons_relations.SOCIAL_CONNECTION_TYPE.PARTNER,
                                               person_1=self.person_1_1,
                                               person_2=self.person_2_1)

        self.bill_data = PersonRemoveSocialConnection(person_1_id=self.person_1_1.id,
                                                      person_2_id=self.person_2_1.id)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #19
0
    def test_update(self):
        declined_bill_2 = BillPrototype.create(
            self.account1,
            "declined-bill-caption",
            "declined-bill-rationale",
            self.declined_bill_data,
            chronicle_on_accepted="chronicle-on-accepted-2",
        )

        data = declined_bill_2.user_form_initials
        data["approved"] = True
        declined_form = declined_bill_2.data.get_moderator_form_update(data)

        self.assertTrue(declined_form.is_valid())
        declined_bill_2.update_by_moderator(declined_form)
        declined_bill_2.apply()

        form = self.bill.data.get_user_form_update(
            post={
                "caption": "new-caption",
                "rationale": "new-rationale",
                "chronicle_on_accepted": "chronicle-on-accepted-3",
                "declined_bill": declined_bill_2.id,
            }
        )
        self.assertTrue(form.is_valid())

        self.bill.update(form)

        self.bill = BillPrototype.get_by_id(self.bill.id)

        self.assertEqual(self.bill.data.declined_bill_id, declined_bill_2.id)
예제 #20
0
    def test_forum_vote_might(self):
        old_might = calculate_might(self.account)
        bill_data = PlaceRenaming(
            place_id=self.place_1.id,
            name_forms=names.generator().get_test_name('bill_place'))
        bill = BillPrototype.create(
            self.account_2,
            'caption',
            'rationale',
            bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
        bill.state = BILL_STATE.REJECTED
        bill.save()

        Post.objects.all().delete()
        Thread.objects.all().delete()
        Vote.objects.all().delete()

        self.assertEqual(calculate_might(self.account_2), old_might)
        self.assertEqual(calculate_might(self.account), 0)

        VotePrototype.create(self.account, bill, VOTE_TYPE.FOR)
        self.assertTrue(calculate_might(self.account) > 0)

        Vote.objects.all().delete()
        VotePrototype.create(self.account, bill, VOTE_TYPE.AGAINST)
        self.assertTrue(calculate_might(self.account) > 0)

        Vote.objects.all().delete()
        VotePrototype.create(self.account, bill, VOTE_TYPE.REFRAINED)
        self.assertEqual(calculate_might(self.account), 0)
예제 #21
0
    def setUp(self):
        super(BuildingCreateTests, self).setUp()

        self.person_1 = sorted(self.place1.persons,
                               key=lambda person: -politic_power_storage.
                               persons.total_power_fraction(person.id))[0]
        self.person_2 = sorted(self.place2.persons,
                               key=lambda person: -politic_power_storage.
                               persons.total_power_fraction(person.id))[-1]

        self.accepted_position_1 = random.choice(
            list(
                places_logic.get_available_positions(
                    center_x=self.person_1.place.x,
                    center_y=self.person_1.place.y)))
        self.accepted_position_2 = random.choice(
            list(
                places_logic.get_available_positions(
                    center_x=self.person_2.place.x,
                    center_y=self.person_2.place.y)))

        self.bill_data = BuildingCreate(
            person_id=self.person_1.id,
            old_place_name_forms=self.place1.utg_name,
            utg_name=names.generator().get_test_name('building-name'),
            x=self.accepted_position_1[0],
            y=self.accepted_position_1[1])
        self.bill = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
예제 #22
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(PersonRemoveSocialConnectionTests, self).setUp()

        self.person_1_1 = self.place1.persons[0]
        self.person_2_1, self.person_2_2 = self.place2.persons[0:2]
        self.person_3_1 = self.place3.persons[0]

        self.account = self.accounts_factory.create_account()

        persons_logic.create_social_connection(
            connection_type=persons_relations.SOCIAL_CONNECTION_TYPE.PARTNER,
            person_1=self.person_1_1,
            person_2=self.person_2_1,
        )

        self.bill_data = PersonRemoveSocialConnection(person_1_id=self.person_1_1.id, person_2_id=self.person_2_1.id)
        self.bill = BillPrototype.create(
            self.account1,
            "bill-1-caption",
            "bill-1-rationale",
            self.bill_data,
            chronicle_on_accepted="chronicle-on-accepted",
        )

        self.person_1_1.politic_power.change_power(
            self.person_1_1, hero_id=self.account.id, has_in_preferences=True, power=100
        )
예제 #24
0
    def create_bill(self, index, owner, state):
        from the_tale.game.bills.bills import PlaceRenaming
        from the_tale.game.bills.prototypes import BillPrototype

        bill_data = PlaceRenaming(place_id=self.place1.id, name_forms=names.generator().get_test_name('new_name_%d' % index))
        bill = BillPrototype.create(owner, 'bill-%d-caption' % index, 'bill-%d-rationale' % index, bill_data, chronicle_on_accepted='chronicle-on-accepted')
        bill.state = state
        bill.save()
예제 #25
0
    def setUp(self):
        super(PersonRemoveTests, self).setUp()

        self.person1 = sorted(self.place1.persons, key=lambda p: -p.total_politic_power_fraction)[0]
        self.person2 = sorted(self.place2.persons, key=lambda p: -p.total_politic_power_fraction)[-1]

        self.bill_data = PersonRemove(person_id=self.person1.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')
예제 #26
0
    def setUp(self):
        super(BillPlaceChangeModifierTests, self).setUp()

        bill_data = bills.PlaceModifier(place_id=self.place1.id, modifier_id=TradeCenter.get_id(), modifier_name=TradeCenter.TYPE.text, old_modifier_name=None)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.form = bills.PlaceModifier.ModeratorForm({'approved': True})
        self.assertTrue(self.form.is_valid())
예제 #27
0
    def setUp(self):
        super(BillPlaceDescriptionTests, self).setUp()

        bill_data = bills.PlaceDescripton(place_id=self.place1.id, description='new description')
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.form = bills.PlaceDescripton.ModeratorForm({'approved': True})
        self.assertTrue(self.form.is_valid())
예제 #28
0
    def setUp(self):
        super(BillPlaceChronicleTests, self).setUp()

        bill_data = bills.PlaceChronicle(place_id=self.place1.id, old_name_forms=self.place1.utg_name, power_bonus=bills_relations.POWER_BONUS_CHANGES.DOWN)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.form = bills.PersonChronicle.ModeratorForm({'approved': True})
        self.assertTrue(self.form.is_valid())
예제 #29
0
    def setUp(self):
        super(PersonChronicleTests, self).setUp()

        self.person1 = sorted(self.place1.persons, key=lambda p: -p.power)[0]
        self.person2 = sorted(self.place2.persons, key=lambda p: -p.power)[-1]

        self.bill_data = PersonChronicle(person_id=self.person1.id, old_place_name_forms=self.place1.utg_name, power_bonus=relations.POWER_BONUS_CHANGES.UP)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #30
0
    def setUp(self):
        super(BillPersonRemoveTests, self).setUp()

        bill_data = bills.PersonRemove(person_id=self.place1.persons[0].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.PersonRemove.ModeratorForm({'approved': True})
        self.assertTrue(self.form.is_valid())
예제 #31
0
    def setUp(self):
        super(BuildingCreateTests, self).setUp()

        self.person_1 = sorted(self.place1.persons, key=lambda p: -p.total_politic_power_fraction)[0]
        self.person_2 = sorted(self.place2.persons, key=lambda p: -p.total_politic_power_fraction)[-1]

        self.bill_data = BuildingCreate(person_id=self.person_1.id, old_place_name_forms=self.place1.utg_name, utg_name=names.generator.get_test_name(u'building-name'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #32
0
    def setUp(self):
        super(TestPrototypeApply, self).setUp()

        bill_data = PlaceRenaming(place_id=self.place1.id, name_forms=names.generator.get_test_name('new_name_1'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.bill.approved_by_moderator = True
        self.bill.save()
예제 #33
0
    def setUp(self):
        super(BuildingCreateTests, self).setUp()

        self.person_1 = sorted(self.place1.persons, key=lambda p: -p.power)[0]
        self.person_2 = sorted(self.place2.persons, key=lambda p: -p.power)[-1]

        self.bill_data = BuildingCreate(person_id=self.person_1.id, old_place_name_forms=self.place1.utg_name, utg_name=names.generator.get_test_name(u'building-name'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #34
0
    def setUp(self):
        super(PersonRemoveTests, self).setUp()

        self.person1 = sorted(self.place1.persons, key=lambda person: -politic_power_storage.persons.total_power_fraction(person.id))[0]
        self.person2 = sorted(self.place2.persons, key=lambda person: -politic_power_storage.persons.total_power_fraction(person.id))[-1]

        self.bill_data = PersonRemove(person_id=self.person1.id, old_place_name_forms=self.place1.utg_name)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #35
0
    def setUp(self):
        super(TestPrototypeApply, self).setUp()

        bill_data = PlaceRenaming(place_id=self.place1.id, name_forms=names.generator().get_test_name('new_name_1'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.bill.approved_by_moderator = True
        self.bill.save()
    def setUp(self):
        super(PersonRemoveTests, self).setUp()

        self.person1 = sorted(self.place1.persons, key=lambda p: -p.power)[0]
        self.person2 = sorted(self.place2.persons, key=lambda p: -p.power)[-1]

        self.bill_data = PersonRemove(person_id=self.person1.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')
예제 #37
0
    def setUp(self):
        super(PlaceModifierTests, self).setUp()

        self.place = self.place1
        self.place_2 = self.place2

        self.bill_data = PlaceModifier(place_id=self.place.id, modifier_id=TradeCenter.get_id(), modifier_name=TradeCenter.TYPE.text, old_modifier_name=None)

        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #38
0
    def setUp(self):
        super(TestPrototypeEnd, self).setUp()

        bill_data = PlaceRenaming(place_id=self.place1.id, name_forms=names.generator().get_test_name('new_name_1'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.bill.state = relations.BILL_STATE.ACCEPTED

        TimePrototype.get_current_time().increment_turn()
예제 #39
0
    def setUp(self):
        super(TestPrototypeEnd, self).setUp()

        bill_data = PlaceRenaming(place_id=self.place1.id, name_forms=names.generator.get_test_name('new_name_1'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.bill.state = relations.BILL_STATE.ACCEPTED

        TimePrototype.get_current_time().increment_turn()
예제 #40
0
    def test_has_meaning__not_connected(self):
        bill_data = PlaceResourceExchange(place_1_id=self.place1.id,
                                          place_2_id=self.place3.id,
                                          resource_1=self.resource_1,
                                          resource_2=self.resource_2)

        bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data,
                                    chronicle_on_accepted='chronicle-on-accepted')

        self.assertFalse(bill.has_meaning())
예제 #41
0
    def setUp(self):
        super(BillPlaceRenamingTests, self).setUp()

        bill_data = bills.PlaceRenaming(place_id=self.place1.id, name_forms=names.generator.get_test_name('new-name'))
        self.bill = BillPrototype.create(self.account1, 'bill-caption', 'bill-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        data = linguistics_helpers.get_word_post_data(bill_data.name_forms, prefix='name')
        data.update({'approved': True})
        self.form = bills.PlaceRenaming.ModeratorForm(data)
        self.assertTrue(self.form.is_valid())
예제 #42
0
    def setUp(self):
        super(PlaceResourceConversionTests, self).setUp()

        self.conversion_1, self.conversion_2 = choose_conversions()

        self.bill_data = PlaceResourceConversion(place_id=self.place1.id,
                                                 conversion=self.conversion_1)

        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data,
                                         chronicle_on_accepted='chronicle-on-accepted')
    def setUp(self):
        super(PlaceDescriptionTests, self).setUp()

        self.place = places_storage.all()[0]
        self.place.description = 'old description'
        self.place.save()

        self.place_2 = places_storage.all()[1]

        self.bill_data = PlaceDescripton(place_id=self.place.id, description='new description')
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #44
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())
예제 #45
0
    def setUp(self):
        super(PlaceDescriptionTests, self).setUp()

        self.place = places_storage.all()[0]
        self.place.description = 'old description'
        self.place.save()

        self.place_2 = places_storage.all()[1]

        self.bill_data = PlaceDescripton(place_id=self.place.id, description='new description')
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #46
0
    def setUp(self):
        super(TestActorPrototype, self).setUp()

        self.bill_data = PlaceRenaming(
            place_id=self.place1.id,
            name_forms=names.generator().get_test_name('new_name_1'))
        self.bill = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
    def test_decline__success(self):
        self.apply_bill()

        old_storage_version = places_storage.resource_exchanges._version

        decliner = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted-2')

        self.bill.decline(decliner)

        self.assertNotEqual(old_storage_version, places_storage.resource_exchanges._version)

        self.assertEqual(len(places_storage.resource_exchanges.all()), 0)
    def setUp(self):
        super(PlaceResourceExchangeTests, self).setUp()

        self.resource_1, self.resource_2 = choose_exchange_resources()

        self.bill_data = PlaceResourceExchange(place_1_id=self.place1.id,
                                               place_2_id=self.place2.id,
                                               resource_1=self.resource_1,
                                               resource_2=self.resource_2)

        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data,
                                         chronicle_on_accepted='chronicle-on-accepted')
예제 #49
0
 def create_bill(self, account=None):
     if account is None:
         account = self.account1
     bill_data = PlaceRenaming(
         place_id=self.place1.id,
         name_forms=names.generator.get_test_name('new_name_1'))
     return BillPrototype.create(
         account,
         'bill-1-caption',
         'bill-1-rationale',
         bill_data,
         chronicle_on_accepted='chronicle-on-accepted')
예제 #50
0
    def setUp(self):
        super(PlaceModifierTests, self).setUp()

        self.place = self.place1
        self.place_2 = self.place2

        self.bill_data = PlaceModifier(place_id=self.place.id,
                                       modifier_id=places_modifiers.CITY_MODIFIERS.TRADE_CENTER,
                                       modifier_name=places_modifiers.CITY_MODIFIERS.TRADE_CENTER.text,
                                       old_modifier_name=None)

        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #51
0
    def setUp(self):
        super(PersonMoveTests, self).setUp()

        self.person_1, self.person_2, self.person_3 = self.place1.persons[0:3]

        self.account = self.accounts_factory.create_account()

        self.person_1.politic_power.change_power(self.person_1, hero_id=self.account.id, has_in_preferences=True, power=100)
        self.person_2.politic_power.change_power(self.person_2, hero_id=self.account.id, has_in_preferences=True, power=200)

        self.bill_data = PersonMove(person_id=self.person_1.id, new_place_id=self.place2.id)
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
예제 #52
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')
예제 #53
0
    def create_bill_decline__exchange(self):
        resource_1, resource_2 = choose_exchange_resources()

        declined_bill_data = bills.PlaceResourceExchange(place_1_id=self.place_1.id,
                                                         place_2_id=self.place_2.id,
                                                         resource_1=resource_1,
                                                         resource_2=resource_2)

        declined_bill = BillPrototype.create(self.account, 'declined-bill-caption', 'declined-bill-rationale', declined_bill_data, chronicle_on_accepted='chronicle-on-accepted')

        declined_data = declined_bill.user_form_initials
        declined_data['approved'] = True

        declined_form = bills.PlaceResourceExchange.ModeratorForm(declined_data)
        self.assertTrue(declined_form.is_valid())
        declined_bill.update_by_moderator(declined_form)
        declined_bill.apply()

        bill_data = bills.BillDecline(declined_bill_id=declined_bill.id)
        bill = BillPrototype.create(self.account, 'bill-caption', 'bill-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')
        return bill, declined_bill