def test_DBManager6(self): dbm = DBManager(self.test_write_root) dbm.getDB('TestDB1') dbm.getDB('TestDB2') dbm.getDB('TestDB3') self.assertIn('TestDB1', dbm.db) self.assertIn('TestDB1', dbm.db_loc) self.assertIn('TestDB2', dbm.db) self.assertIn('TestDB2', dbm.db_loc) self.assertIn('TestDB3', dbm.db) self.assertIn('TestDB3', dbm.db_loc) rootdb = dbm.getDB(dbm.rootdb_key) cs = rootdb.cursor() cs.execute('select db from DB') dbs = [str(r[0]) for r in cs.fetchall()] self.assertSequenceEqual(['TestDB1', 'TestDB2', 'TestDB3'], dbs) cs.close() dbm.close('TestDB2') self.assertIn('TestDB1', dbm.db) self.assertIn('TestDB1', dbm.db_loc) self.assertNotIn('TestDB2', dbm.db) self.assertNotIn('TestDB2', dbm.db_loc) self.assertIn('TestDB3', dbm.db) self.assertIn('TestDB3', dbm.db_loc) dbm.close() self.assertDictEqual(dbm.db, {}) self.assertDictEqual(dbm.db_loc, {})
def test_DBManager2(self): dbm = DBManager(self.test_write_root) dbm.getDB('TestDB1') db1_path = dbm.getDBloc('TestDB1') ref1_path = os.path.abspath( os.path.join(self.test_write_root, 'TestDB1.db')) self.assertEqual(ref1_path, db1_path) db_created = dbm.getDB('TestDB2') db_opened = dbm.getDB('TestDB2') self.assertEqual(db_created, db_opened) dbm.close()
def test_DBManager4(self): dbm = DBManager(self.test_write_root) with self.assertRaises(Error): dbm.getDB(tuple()) self.assertIsNone(dbm.getDBloc(tuple())) dbm.close()