def testRestore(self): self.testSplit() path = self.htree.path l = len(self.htree) h = hash(self.htree) self.htree.close() import pytc db = pytc.HDB() db.open(path, pytc.HDBOREADER | pytc.HDBOWRITER) try: db.out("__pool__") except: pass db.close() t = HTree(path, 0) self.assertEqual(len(t), l) self.assertEqual(hash(t), h) t.close() import pytc db = pytc.HDB() db.open(path, pytc.HDBOREADER | pytc.HDBOWRITER) #assert db["__sync__"] == "1" try: db.out("__sync__") except: pass db.close() t = HTree(path, 0) self.assertEqual(len(t), l) self.assertEqual(hash(t), h) t.close()
def testSave(self): self.testSplit() path = self.htree.path l = len(self.htree) h = hash(self.htree) self.htree.close() t = HTree(path, 0) self.assertEqual(len(t), l) self.assertEqual(hash(t), h) t.close()
def testDepth(self): self.testSplit() h, c = self.htree.get_hash("@1") s = self.htree.list("1") t = HTree("tt.tch", 1) for key, ver, ha in [l.split(' ') for l in s.split("\n") if l]: t.add(key, int(ver), int(ha)) self.assertEqual(len(t), c) self.assertEqual(hash(t), h) self.assertEqual(t.list(''), s) t.close() os.unlink('tt.tch')
def setUp(self): self.htree = HTree("t.tch", 0) self.htree.clear()