def runTest(self): """ Tests that we can successfully delete a building via the Building page """ # Test the deletion of the building my_building = Building.selectBy(name=self.building_name).getOne() building_id = my_building.id post_params = {"action": "delete", "id": str(building_id)} # Do the request and verify that it has been deleted and that there is no empty body r = self.testApp.post('/buildings', params=post_params, status=200) assert Building.selectBy(id=building_id).getOne(default=None) is None assert r.body is not None
def runTest(self): """ Tests that we can successfully create a building via the Building page """ # Verify that there is no building with this name in db assert Building.selectBy(name=self.new_building_name).getOne( default=None) is None # Do the post request to create the building r = self.testApp.post('/buildings', params=self.post_params, status=200) select_result = Building.selectBy(name=self.new_building_name) # verify that the building has been created (exactly one), with the correct name and that there is no empty body assert select_result.getOne().name == self.new_building_name assert select_result.getOne().city == self.new_building_city assert r.body is not None Building.deleteBy(name=self.new_building_name)
def runTest(self): """ Tests the Building object. """ try: Building(name="test") except DuplicateEntryError: assert_true(False) b = Building.selectBy(name="test").getOne() assert_not_equal(b, None) assert_equal(b.name, "test") try: b.set(name="newName") except DuplicateEntryError: assert_true(False) assert_equal(b.name, "newName") b.set(name="test") t = Building.delete(b.id) assert_equal(t, None) t = Building.selectBy(name="test").getOne(None) assert_equal(t, None)
def runTest(self): """ Tests that we can successfully delete a building via the Building page """ new_name = "BuildingNewName" new_city = "BuildingNewCity" post_params = { "action": "edit", "id": str(self.building_id), "name": new_name, "city": new_city } # Do the request r = self.testApp.post('/buildings', params=post_params, status=200) # check that the old name is not there anymore assert Building.selectBy(name=self.building_name).getOne( default=None) is None # check that the building still has the same id but the new name assert Building.get(self.building_id).name == new_name assert Building.get(self.building_id).city == new_city assert r.body is not None