def test_has_meaning__no_building(self): self.assertEqual( Building.objects.filter(state=BUILDING_STATE.WORKING).count(), 2) VotePrototype.create(self.account2, self.bill, False) VotePrototype.create(self.account3, self.bill, True) form = BuildingDestroy.ModeratorForm({'approved': True}) self.assertTrue(form.is_valid()) self.bill.update_by_moderator(form) self.building_1.destroy() self.building_1.save() self.assertFalse(self.bill.has_meaning())
def test_has_meaning__duplicate(self): self.assertEqual( Building.objects.filter(state=BUILDING_STATE.WORKING).count(), 2) VotePrototype.create(self.account2, self.bill, False) VotePrototype.create(self.account3, self.bill, True) form = BuildingDestroy.ModeratorForm({'approved': True}) self.assertTrue(form.is_valid()) self.bill.update_by_moderator(form) self.assertTrue(self.bill.apply()) bill = BillPrototype.get_by_id(self.bill.id) bill.state = BILL_STATE.VOTING bill.save() self.assertFalse(bill.has_meaning())
def test_apply(self): self.assertEqual(Building.objects.filter(state=BUILDING_STATE.WORKING).count(), 2) VotePrototype.create(self.account2, self.bill, False) VotePrototype.create(self.account3, self.bill, True) form = BuildingDestroy.ModeratorForm({'approved': True}) self.assertTrue(form.is_valid()) self.bill.update_by_moderator(form) self.assertTrue(self.bill.apply()) bill = BillPrototype.get_by_id(self.bill.id) self.assertTrue(bill.state.is_ACCEPTED) self.assertEqual(Building.objects.filter(state=BUILDING_STATE.WORKING).count(), 1) self.assertEqual(len(buildings_storage.all()), 1) building = buildings_storage.all()[0] self.assertNotEqual(building.id, self.building_1.id)