summaryrefslogtreecommitdiff
path: root/tests/server_commands.py
diff options
context:
space:
mode:
authorandy <andy@whiskeymedia.com>2012-10-07 22:31:55 -0700
committerandy <andy@whiskeymedia.com>2012-10-07 22:31:55 -0700
commit6e7a710fe480816d2abe27263a9975332c939c6f (patch)
treeaddf0cd66d7412b189385404648220c1dfe2c33d /tests/server_commands.py
parente85056eb37cbc3289c8ab321af38f04e58882e80 (diff)
downloadredis-py-6e7a710fe480816d2abe27263a9975332c939c6f.tar.gz
INCRBYFLOAT/HINCRBYFLOAT
Diffstat (limited to 'tests/server_commands.py')
-rw-r--r--tests/server_commands.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/server_commands.py b/tests/server_commands.py
index 19d628a..d3616eb 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -347,6 +347,19 @@ class ServerCommandsTestCase(unittest.TestCase):
self.assertEquals(self.client.incr('a', amount=5), 7)
self.assertEquals(self.client['a'], b('7'))
+ def test_incrbyfloat(self):
+ version = self.client.info()['redis_version']
+ if StrictVersion(version) < StrictVersion('2.6.0'):
+ try:
+ raise unittest.SkipTest()
+ except AttributeError:
+ return
+
+ self.assertEquals(self.client.incrbyfloat('a'), 1.0)
+ self.assertEquals(self.client['a'], b('1'))
+ self.assertEquals(self.client.incrbyfloat('a', 1.1), 2.1)
+ self.assertEquals(self.client['a'], b('2.1'))
+
def test_keys(self):
self.assertEquals(self.client.keys(), [])
keys = set([b('test_a'), b('test_b'), b('testc')])
@@ -1340,6 +1353,17 @@ class ServerCommandsTestCase(unittest.TestCase):
self.client.hset('a', 'a3', 'foo')
self.assertRaises(redis.ResponseError, self.client.hincrby, 'a', 'a3')
+ def test_hincrbyfloat(self):
+ # key is not a hash
+ self.client['a'] = 'a'
+ self.assertRaises(redis.ResponseError,
+ self.client.hincrbyfloat, 'a', 'a1')
+ del self.client['a']
+ # no key should create the hash and incr the key's value to 1
+ self.assertEquals(self.client.hincrbyfloat('a', 'a1'), 1.0)
+ self.assertEquals(self.client.hincrbyfloat('a', 'a1'), 2.0)
+ self.assertEquals(self.client.hincrbyfloat('a', 'a1', 1.2), 3.2)
+
def test_hkeys(self):
# key is not a hash
self.client['a'] = 'a'