summaryrefslogtreecommitdiff
path: root/tests/server_commands.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2011-02-09 10:08:09 -0800
committerAndy McCurdy <andy@andymccurdy.com>2011-02-09 10:08:09 -0800
commit4ff702dd0b05355864ea47dfff78ccce262f3fb3 (patch)
tree0168ec5dbcf40d97e3ebabbc65ed4d6ddcbcbab5 /tests/server_commands.py
parentd74cff87729ab9d815fe7a861d630f417306a3b9 (diff)
downloadredis-py-4ff702dd0b05355864ea47dfff78ccce262f3fb3.tar.gz
stylistic modes + tests for zrevrangebyscore
Diffstat (limited to 'tests/server_commands.py')
-rw-r--r--tests/server_commands.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/server_commands.py b/tests/server_commands.py
index 5cd63c5..fa47726 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -879,6 +879,28 @@ class ServerCommandsTestCase(unittest.TestCase):
# a non existant key should return empty list
self.assertEquals(self.client.zrange('b', 0, 1, withscores=True), [])
+ def test_zrangebyscore(self):
+ # key is not a zset
+ self.client['a'] = 'a'
+ self.assertRaises(redis.ResponseError, self.client.zrevrangebyscore,
+ 'a', 0, 1)
+ del self.client['a']
+ # real logic
+ self.make_zset('a', {'a1': 1, 'a2': 2, 'a3': 3, 'a4': 4, 'a5': 5})
+ self.assertEquals(
+ self.client.zrevrangebyscore('a', 4, 2),
+ ['a4', 'a3', 'a2'])
+ self.assertEquals(
+ self.client.zrevrangebyscore('a', 4, 2, start=1, num=2),
+ ['a3', 'a2'])
+ self.assertEquals(
+ self.client.zrevrangebyscore('a', 4, 2, withscores=True),
+ [('a4', 4.0), ('a3', 3.0), ('a2', 2.0)])
+ # a non existant key should return empty list
+ self.assertEquals(
+ self.client.zrevrangebyscore('b', 1, 0, withscores=True),
+ [])
+
def test_zrevrank(self):
# key is not a zset
self.client['a'] = 'a'