def test_addDrop(self): a = InMemoryDROP('a', 'a') registry = RDBMSRegistry('sqlite3', DBFILE) registry.addDrop(a) conn = sqlite3.connect(DBFILE) # @UndefinedVariable cur = conn.cursor() cur.execute('SELECT oid FROM dlg_drop'); r = cur.fetchone() self.assertEqual(1, len(r)) self.assertEqual('a', r[0]) cur.close() conn.close()
def test_addDropInstances(self): a1 = InMemoryDROP('a', 'a1') a2 = InMemoryDROP('a', 'a2') registry = RDBMSRegistry('sqlite3', DBFILE) registry.addDrop(a1) uids = registry.getDropUids(a1) self.assertEqual(1, len(uids)) self.assertEqual('a1', uids[0]) registry.addDropInstance(a2) uids = registry.getDropUids(a1) uids.sort() self.assertEqual(2, len(uids)) self.assertEqual('a1', uids[0]) self.assertEqual('a2', uids[1]) # Check accessing the database separately conn = sqlite3.connect(DBFILE) # @UndefinedVariable cur = conn.cursor() cur.execute("SELECT uid FROM dlg_dropinstance WHERE oid = 'a'"); rows = cur.fetchall() self.assertEqual(2, len(rows)) uids = [r[0] for r in rows] uids.sort() self.assertEqual(2, len(uids)) self.assertEqual('a1', uids[0]) self.assertEqual('a2', uids[1]) cur.close() conn.close()
def test_dropAccess(self): a1 = InMemoryDROP('a', 'a1') registry = RDBMSRegistry('sqlite3', DBFILE) registry.addDrop(a1) self.assertEqual(-1, registry.getLastAccess('a')) registry.recordNewAccess('a') self.assertNotEqual(-1, registry.getLastAccess('a'))
def test_dropAccess(self): a1 = InMemoryDROP("a", "a1") registry = RDBMSRegistry("sqlite3", DBFILE) registry.addDrop(a1) self.assertEqual(-1, registry.getLastAccess("a")) registry.recordNewAccess("a") self.assertNotEqual(-1, registry.getLastAccess("a"))