def testGetTableNames(self): for datafile in self.datafiles: # create temp db connection db = Datafile(getTestFileName(datafile)) db.openConnection() # generate expected/actual results expected = getTestFileTables(datafile) actual = db.getTableNames() # close db connection db.closeConnection() # assert table names match self.assertCountEqual(expected, actual)
class TestGetSingularTableSuccess(TestCase): def setUp(self): self.onetable_db_filepath = getTestFileName('single_simple_table') self.onetable_db = Datafile(self.onetable_db_filepath, debug=True) self.tables = getTestFileTables('single_simple_table') if len(self.tables) != 1: raise Exception('Bad test db setup -- should only contain 1 table') def testSuccess(self): self.onetable_db.openConnection() expected = self.tables[0] actual = self.onetable_db.getSingularTable() self.onetable_db.closeConnection() self.assertEqual(expected, actual)
class TestSqliteConnectionOpen(TestCase): def setUp(self): self.existing_db_filepath = getTestFileName('single_simple_table') self.existing_db = Datafile(self.existing_db_filepath, debug=True) self.existing_db.openConnection() def testConnectionCreated(self): self.assertTrue( hasattr(self.existing_db, 'connection') and type(self.existing_db.connection) is DbConnection) def testConnectionClosed(self): self.existing_db.closeConnection() self.assertFalse( hasattr(self.existing_db, 'connection') and type(self.existing_db.connection) is DbConnection)