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