Commits

Tomasz Rybarczyk committed 1641a90

Add `items` method

Comments (0)

Files changed (2)

         assert isinstance(key, str)
         self._redis.hdel(self.name, key)
 
+    def items(self):
+        return [(k, self._deserialize(v)) for k,v in self._redis.hgetall(self.name).items()]
+
     def execute_update(self, key, updater):
         with self._redis.pipeline() as pipe:
             pipe.watch(self.name)
         self.redis_dict['two'] = 2
         self.redis_dict.execute_update('one', lambda v: v+100)
         self.assertEqual(self.redis_dict['one'], 101)
+
+    def test_items_method(self):
+        self.redis_dict['one'] = 1
+        self.redis_dict['two'] = 2
+        self.assertEqual(set([('one', 1), ('two', 2)]), set(self.redis_dict.items()))