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)
Exemple #2
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())