def teardown_class(self): """ This method tears down the testing logic to ensure that no data remains after testing that shouldn't. In this case, it closes the database session. """ with transaction.manager: for run in DBSession.query(Run).all(): # Delete every run in the session. DBSession.delete(run) DBSession.commit() # Close the session. DBSession.remove() testing.tearDown()
def teardown_class(self): """ This method tears down the class after testing has been completed, in order to ensure no data exists after testing that shouldn't. In this case, closes down the database session. """ with transaction.manager: for run in DBSession.query(Run).all(): # Delete all runs in the database. DBSession.delete(run) DBSession.commit() # Close the database session. DBSession.remove() testing.tearDown()
def test_delete(self): ''' Test run deletion ''' # Delete the run inserted by this test runs = DBSession.query(Run).filter(Run.user_name==self._insert_name) assert runs.all() for run in runs: DBSession.delete(run) DBSession.commit() # Ensure deletion runs = DBSession.query(Run).filter(Run.user_name==self._insert_name) assert not runs.all()
def test_delete(self): """ This method tests the ability of the runs table to delete data from it. The expected result of this is for the data to be correctly deleted from the table. """ # Delete the run inserted by this test runs = DBSession.query(Run).filter(Run.user_name==self._insert_name) # Assert that the runs have been retrieved assert runs.all() for run in runs: DBSession.delete(run) DBSession.commit() runs = DBSession.query(Run).filter(Run.user_name==self._insert_name) # Assert that the selected runs have been deleted. assert not runs.all()