Fixed mock implementation of hgetall
authorEd Bartosh <eduard.bartosh@intel.com>
Sun, 10 Aug 2014 21:40:13 +0000 (00:40 +0300)
committerLin A Yang <lin.a.yang@intel.com>
Wed, 13 Aug 2014 04:14:04 +0000 (07:14 +0300)
python-redis:hgetall returns empty dictionary if key doesn't exist.
This commit fixes this in mock. Previously it returned None in this
case.

Change-Id: I76f38d15d3918f0b7bbd41d9f3e1907f5e3b61db
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
tests/test_backenddb.py

index 1aa9784..08bb73f 100644 (file)
@@ -106,7 +106,7 @@ class RedisMock(object):
 
     def hgetall(self, key):
         """Get all the fields and values in a hash."""
-        return self._dict.get(key)
+        return self._dict.get(key, {})
 
     def rpush(self, key, item):
         """Add item to the list."""