Add state test on sync test

This commit is contained in:
lash 2022-04-20 16:59:25 +00:00
parent f00cb9564d
commit 16d4898ff3
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 14 additions and 3 deletions

View File

@ -71,12 +71,14 @@ class RocksDbStore:
r = [] r = []
l = len(self.__path) l = len(self.__path)
for (k, v) in it: import sys
for (kb, v) in it:
k = kb.decode('utf-8')
if len(k) < l or k[:l] != self.__path: if len(k) < l or k[:l] != self.__path:
break break
k = self.__from_path(s) k = self.__from_path(k)
kb = self.__to_key(k)
v = self.db.get(kb) v = self.db.get(kb)
sys.stderr.write('ls keys {} {} {}\n'.format(k, kb, v))
r.append((k, v,)) r.append((k, v,))
return r return r

View File

@ -181,9 +181,17 @@ class TestFileStore(unittest.TestCase):
f.write('barbar') f.write('barbar')
f.close() f.close()
fp = os.path.join(self.d, 'BAR', 'yyyy')
f = open(fp, 'w')
f.close()
self.states.sync() self.states.sync()
self.assertEqual(self.states.get('abcd'), None) self.assertEqual(self.states.get('abcd'), None)
self.assertEqual(self.states.state('abcd'), self.states.FOO)
self.assertEqual(self.states.get('zzzz'), 'barbar') self.assertEqual(self.states.get('zzzz'), 'barbar')
self.assertEqual(self.states.state('zzzz'), self.states.BAR)
self.assertEqual(self.states.get('yyyy'), None)
self.assertEqual(self.states.state('yyyy'), self.states.BAR)
def test_path(self): def test_path(self):
@ -234,5 +242,6 @@ class TestFileStore(unittest.TestCase):
self.assertEqual(r, 'foo') self.assertEqual(r, 'foo')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()