def _restoreTables(dbname): tables = {} con = DatabaseConnector() for tablename in con.getDatabaseTables(dbname): table = Table.restore(dbname, tablename) tables[table.name] = table con.close() return tables
def test_create(self, saveOnStorage): table = Table.create('', [], [], '') self.assertEqual(table.creatorDbRoot, '') self.assertEqual(table.name, '') self.assertEqual(table.columns, []) self.assertEqual(table.types, []) self.assertEqual(table.records, []) self.assertEqual(saveOnStorage.call_count, 1)
def test_create_non_unique_columns(self): with self.assertRaises(ValueError): table = Table.create('', ['123', '123'], [], '')
def test_restore_from_non_existing_file(self): with self.assertRaises(Exception): table = Table.restore('nonexisting.file')
def setUp(self, saveOnStorage): self.table = Table.create( name='name', columnNames=['int', 'float', 'str', 'segment', 'image'], columnTypes=['int', 'float', 'str', 'segment', 'image'], databaseRoot='')
def test_create_unsupported_type(self): with self.assertRaises(ValueError): table = Table.create('', ['123'], ['unsupportedtype'], '')
def test_create_unequal_params_length(self): with self.assertRaises(ValueError): table = Table.create('', [ '123', ], ['int', 'str'], '')
def addTable(self, name, columns, types): if name in self.tables.keys(): raise Exception('Table ' + "'" + name + "'" + ' already exists') self.tables[name] = Table.create(name, self.name, columns, types)