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

        old_storage_version = resource_exchange_storage._version

        self.assertEqual(len(resource_exchange_storage.all()), 1)

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

        self.assertTrue(self.bill.apply())

        self.bill.state = BILL_STATE.VOTING
        self.bill.save()

        with mock.patch('the_tale.game.bills.prototypes.BillPrototype.decline') as skipped_decline:
            self.assertTrue(self.bill.apply())

        self.assertEqual(skipped_decline.call_count, 0)

        self.assertNotEqual(old_storage_version, resource_exchange_storage._version)
        self.assertEqual(len(resource_exchange_storage.all()), 0)

        bill = BillPrototype.get_by_id(self.bill.id)
        self.assertTrue(bill.state.is_ACCEPTED)

        declined_bill = BillPrototype.get_by_id(self.declined_bill.id)
        self.assertTrue(declined_bill.state.is_ACCEPTED)
        self.assertTrue(declined_bill.is_declined)
        self.assertTrue(declined_bill.declined_by.id, bill.id)
Exemplo n.º 2
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',
        )
Exemplo n.º 3
0
    def test_apply(self):
        VotePrototype.create(self.account2, self.bill, False)
        VotePrototype.create(self.account3, self.bill, True)

        old_storage_version = places_storage.resource_exchanges._version

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

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

        self.assertTrue(self.bill.apply())

        self.assertNotEqual(old_storage_version,
                            places_storage.resource_exchanges._version)
        self.assertEqual(len(places_storage.resource_exchanges.all()), 0)

        bill = BillPrototype.get_by_id(self.bill.id)
        self.assertTrue(bill.state.is_ACCEPTED)

        declined_bill = BillPrototype.get_by_id(self.declined_bill.id)
        self.assertTrue(declined_bill.state.is_ACCEPTED)
        self.assertTrue(declined_bill.is_declined)
        self.assertTrue(declined_bill.declined_by.id, bill.id)
    def test_has_meaning(self):
        VotePrototype.create(self.account2, self.bill, False)
        VotePrototype.create(self.account3, self.bill, True)

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

        self.assertTrue(self.bill.has_meaning())

        self.declined_bill.is_declined = True
        self.declined_bill.save()

        self.assertFalse(self.bill.has_meaning())