def setUp(self): super(BuildingDestroyTests, self).setUp() self.person_1 = self.place1.persons[0] self.person_2 = self.place2.persons[0] self.person_3 = self.place3.persons[0] self.building_1 = BuildingPrototype.create(self.person_1, utg_name=names.generator.get_test_name('building-name-1')) self.building_2 = BuildingPrototype.create(self.person_2, utg_name=names.generator.get_test_name('building-name-2')) self.bill_data = BuildingDestroy(person_id=self.person_1.id, old_place_name_forms=self.place1.utg_name) self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
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)