def test_apply_bills__stop_bill_without_meaning(self):
        from the_tale.forum.models import Category, SubCategory

        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)

        new_name = names.generator.get_test_name('new-new-name')

        bill_data_1 = bills.PlaceRenaming(place_id=self.p1.id, name_forms=new_name)
        bill_1 = bills_prototypes.BillPrototype.create(self.account, 'bill-1-caption', 'bill-1-rationale', bill_data_1, chronicle_on_accepted='chronicle-on-accepted')
        bill_1.approved_by_moderator = True
        bill_1.save()

        bill_data_2 = bills.PlaceRenaming(place_id=self.p1.id, name_forms=new_name)
        bill_2 = bills_prototypes.BillPrototype.create(self.account, 'bill-2-caption', 'bill-2-rationale', bill_data_2, chronicle_on_accepted='chronicle-on-accepted')
        bill_2.approved_by_moderator = True
        bill_2.save()

        self.worker.apply_bills()

        bill_1.reload()
        bill_2.reload()

        self.assertTrue(bill_1.state.is_ACCEPTED)
        self.assertTrue(bill_2.state.is_STOPPED)
예제 #2
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')
예제 #3
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())
예제 #4
0
    def test_get_exchanges_for_bill_id__exists(self):
        from the_tale.accounts.prototypes import AccountPrototype
        from the_tale.accounts.logic import register_user

        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

        result, account_id, bundle_id = register_user('test_user',
                                                      '*****@*****.**',
                                                      '111111')
        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'))
        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,
            resource_exchange_storage.get_exchange_for_bill_id(bill.id).id)
예제 #5
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_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)
예제 #6
0
    def setUp(self):
        super(RecordTests, self).setUp()
        self.place_1, self.place_2, self.place_3 = create_test_map()

        self.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'))
        self.bill = BillPrototype.create(
            self.account,
            'bill-caption',
            bill_data,
            chronicle_on_accepted='chronicle-on-accepted')