summaryrefslogtreecommitdiff
path: root/tests/server_commands.py
diff options
context:
space:
mode:
authorsebleier <sebleier@gmail.com>2010-05-30 04:56:19 +0800
committerAndy McCurdy <andy@andymccurdy.com>2010-06-02 01:41:59 +0800
commit9f0ed62fbc1e648207478c24342512acb3ea01aa (patch)
tree86de73c0478f38fa581c98f8fbf86784b4ac2aed /tests/server_commands.py
parentdd8421273d4b17adfda56e8b753bdf92d4d43fb5 (diff)
downloadredis-py-9f0ed62fbc1e648207478c24342512acb3ea01aa.tar.gz
Added HSETNX command and tests
Diffstat (limited to 'tests/server_commands.py')
-rw-r--r--tests/server_commands.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/server_commands.py b/tests/server_commands.py
index 9024762..5e706e3 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -648,7 +648,7 @@ class ServerCommandsTestCase(unittest.TestCase):
self.client.zrange('z', 0, -1, withscores=True),
[('a3', 20), ('a1', 23)]
)
-
+
def test_zrange(self):
# key is not a zset
@@ -770,7 +770,7 @@ class ServerCommandsTestCase(unittest.TestCase):
self.make_zset('a', {'a1': 1, 'a2': 1, 'a3': 1})
self.make_zset('b', {'a1': 2, 'a3': 2, 'a4': 2})
self.make_zset('c', {'a1': 6, 'a4': 5, 'a5': 4})
-
+
# sum, no weight
self.assert_(self.client.zunionstore('z', ['a', 'b', 'c']))
self.assertEquals(
@@ -819,6 +819,14 @@ class ServerCommandsTestCase(unittest.TestCase):
# key inside of hash that doesn't exist returns null value
self.assertEquals(self.client.hget('a', 'b'), None)
+ def test_hsetnx(self):
+ # Initially set the hash field
+ self.client.hsetnx('a', 'a1', 1)
+ self.assertEqual(self.client.hget('a', 'a1'), '1')
+ # Try and set the existing hash field to a different value
+ self.client.hsetnx('a', 'a1', 2)
+ self.assertEqual(self.client.hget('a', 'a1'), '1')
+
def test_hmset(self):
d = {'a': '1', 'b': '2', 'c': '3'}
self.assert_(self.client.hmset('foo', d))