Ejemplo n.º 1
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)

        declined_form = PlaceResourceExchange.ModeratorForm({'approved': True})
        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',
        )
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def apply_bill(self):
        VotePrototype.create(self.account2, self.bill, False)
        VotePrototype.create(self.account3, self.bill, True)

        form = PlaceResourceExchange.ModeratorForm({'approved': True})
        self.assertTrue(form.is_valid())
        self.bill.update_by_moderator(form)

        self.assertEqual(len(places_storage.resource_exchanges.all()), 0)

        self.assertTrue(self.bill.apply())
Ejemplo n.º 4
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_data,
            chronicle_on_accepted='chronicle-on-accepted')

        self.assertFalse(bill.has_meaning())
Ejemplo n.º 5
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',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
Ejemplo n.º 6
0
    def setUp(self):
        from the_tale.game.bills.tests.helpers import choose_exchange_resources
        from the_tale.game.bills.bills import PlaceResourceExchange

        super(BillPlaceExchangeResourcesTests, 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')

        self.form = bills.PlaceModifier.ModeratorForm({'approved': True})
        self.assertTrue(self.form.is_valid())