Beispiel #1
0
class TestGetSingularTableZeroTables(TestCase):
    def setUp(self):
        self.zerotable_db_filepath = getTestFileName('zero_tables')
        self.zerotable_db = Datafile(self.zerotable_db_filepath, debug=True)
        self.tables = getTestFileTables('zero_tables')
        if len(self.tables) != 0:
            raise Exception('Bad test db setup -- should contain 0 tables')

    def testZeroFail(self):
        self.zerotable_db.openConnection()
        self.assertRaises(Exception, self.zerotable_db.getSingularTable)
Beispiel #2
0
 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)
Beispiel #3
0
class TestGetSingularTableMultipleTables(TestCase):
    def setUp(self):
        self.multitable_db_filepath = getTestFileName(
            'four_tables_cnx_metadata')
        self.multitable_db = Datafile(self.multitable_db_filepath, debug=True)
        self.tables = getTestFileTables('four_tables_cnx_metadata')
        if len(self.tables) <= 1:
            raise Exception('Bad test db setup -- should contain >1 tables')

    def testMultiFail(self):
        self.multitable_db.openConnection()
        self.assertRaises(Exception, self.multitable_db.getSingularTable)
Beispiel #4
0
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)
Beispiel #5
0
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)