api/stores: fix the handling of falsy not None values
3 files changed, 9 insertions(+), 3 deletions(-)

M dbcache/api.py
M test/test_kvstore.py
M test/test_vkvstore.py
M dbcache/api.py +2 -3
@@ 145,8 145,7 @@ class kvstore:
                 key=key
             )
             value = q.do(cn).scalar()
-            if value:
-                return value
+            return value
 
     def set(self, key, value):
         with self.engine.begin() as cn:

          
@@ 202,7 201,7 @@ class vkvstore:
                 key=key,
                 idate=insertion_date
             ).scalar()
-            if value:
+            if value is not None:
                 return value.tobytes()
 
     def versions(self, key: str):

          
M test/test_kvstore.py +3 -0
@@ 22,3 22,6 @@ def test_store(store):
     }
 
     assert store.keys() == ['dict', 'float', 'int']
+
+    store.set('list', [])
+    assert store.get('list') == []

          
M test/test_vkvstore.py +4 -0
@@ 20,6 20,10 @@ def test_vstore(vstore):
     assert vstore.keys() == []
     assert vstore.get('a') is None
 
+    vstore.set('notmuch', b'')
+    assert vstore.get('notmuch') == b''
+    vstore.delete('notmuch')
+
 
 def test_versions(vstore):
     assert vstore.get('html') is None