shep

Multi-state key stores using bit masks for python3
git clone git://git.defalsify.org/shep.git
Log | Files | Refs | LICENSE

commit 16d4898ff3cff2bee504aee13bb7b378a4fe9358
parent f00cb9564d10badbf60f24f856bd38316a449ace
Author: lash <dev@holbrook.no>
Date:   Wed, 20 Apr 2022 16:59:25 +0000

Add state test on sync test

Diffstat:
Mshep/store/rocksdb.py | 8+++++---
Mtests/test_file.py | 9+++++++++
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/shep/store/rocksdb.py b/shep/store/rocksdb.py @@ -71,12 +71,14 @@ class RocksDbStore: r = [] 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: break - k = self.__from_path(s) - kb = self.__to_key(k) + k = self.__from_path(k) v = self.db.get(kb) + sys.stderr.write('ls keys {} {} {}\n'.format(k, kb, v)) r.append((k, v,)) return r diff --git a/tests/test_file.py b/tests/test_file.py @@ -181,9 +181,17 @@ class TestFileStore(unittest.TestCase): f.write('barbar') f.close() + fp = os.path.join(self.d, 'BAR', 'yyyy') + f = open(fp, 'w') + f.close() + self.states.sync() 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.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): @@ -234,5 +242,6 @@ class TestFileStore(unittest.TestCase): self.assertEqual(r, 'foo') + if __name__ == '__main__': unittest.main()