summaryrefslogtreecommitdiff
path: root/tests/server_commands.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2010-03-18 10:19:54 -0700
committerAndy McCurdy <andy@andymccurdy.com>2010-03-18 10:19:54 -0700
commit97ed01d9ac6fe39a53dd9414085f5aa0e44f6041 (patch)
tree70045e9decada18918adedd1a891af2c759f3593 /tests/server_commands.py
parent5723a5468c4c168e798cecd72d21922f9c53d2e8 (diff)
downloadredis-py-97ed01d9ac6fe39a53dd9414085f5aa0e44f6041.tar.gz
HEXISTS and HLEN implementations
added a socket_timeout parameter to allow commands to timeout and raise an error
Diffstat (limited to 'tests/server_commands.py')
-rw-r--r--tests/server_commands.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/server_commands.py b/tests/server_commands.py
index 4d0fa20..aca8a17 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -728,6 +728,20 @@ class ServerCommandsTestCase(unittest.TestCase):
self.assert_(self.client.hdel('a', 'a2'))
self.assertEquals(self.client.hget('a', 'a2'), None)
+ def test_hexists(self):
+ # key is not a hash
+ self.client['a'] = 'a'
+ self.assertRaises(redis.ResponseError, self.client.hexists, 'a', 'a1')
+ del self.client['a']
+ # no key
+ self.assertEquals(self.client.hexists('a', 'a1'), False)
+ # real logic
+ self.make_hash('a', {'a1': 1, 'a2': 2, 'a3': 3})
+ self.assertEquals(self.client.hexists('a', 'a1'), True)
+ self.assertEquals(self.client.hexists('a', 'a4'), False)
+ self.client.hdel('a', 'a1')
+ self.assertEquals(self.client.hexists('a', 'a1'), False)
+
def test_hgetall(self):
# key is not a hash
self.client['a'] = 'a'
@@ -758,6 +772,19 @@ class ServerCommandsTestCase(unittest.TestCase):
remote_keys.sort()
self.assertEquals(keys, remote_keys)
+ def test_hlen(self):
+ # key is not a hash
+ self.client['a'] = 'a'
+ self.assertRaises(redis.ResponseError, self.client.hlen, 'a')
+ del self.client['a']
+ # no key
+ self.assertEquals(self.client.hlen('a'), 0)
+ # real logic
+ self.make_hash('a', {'a1': 1, 'a2': 2, 'a3': 3})
+ self.assertEquals(self.client.hlen('a'), 3)
+ self.client.hdel('a', 'a3')
+ self.assertEquals(self.client.hlen('a'), 2)
+
def test_hvals(self):
# key is not a hash
self.client['a'] = 'a'