Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
redis version check in server commands tests
Browse files Browse the repository at this point in the history
  • Loading branch information
popravich committed Mar 4, 2016
1 parent ff7cd85 commit adb1794
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/server_commands_test.py
Expand Up @@ -3,7 +3,7 @@
from unittest import mock

from aioredis import ReplyError
from ._testutil import RedisTest, run_until_complete
from ._testutil import RedisTest, run_until_complete, REDIS_VERSION


class ServerCommandsTest(RedisTest):
Expand All @@ -13,8 +13,7 @@ def test_client_list(self):
res = yield from self.redis.client_list()
self.assertIsInstance(res, list)
res = [dict(i._asdict()) for i in res]
self.assertEqual(res, [{
'id': mock.ANY,
expected = {
'addr': mock.ANY,
'fd': mock.ANY,
'age': '0',
Expand All @@ -32,9 +31,14 @@ def test_client_list(self):
'events': 'r',
'cmd': 'client',
'name': '',
}])
}
if REDIS_VERSION >= (2, 8, 12):
expected['id'] = mock.ANY
self.assertEqual(res, [expected])

@run_until_complete
@unittest.skipIf(REDIS_VERSION < (2, 9, 50),
'CLIENT PAUSE is available since redis>=2.9.50')
def test_client_pause(self):
res = yield from self.redis.client_pause(2000)
self.assertTrue(res)
Expand Down Expand Up @@ -76,7 +80,7 @@ def test_config_get(self):

@run_until_complete
def test_config_rewrite(self):
with self.assertRaisesRegexp(ReplyError, "Permission denied"):
with self.assertRaises(ReplyError):
yield from self.redis.config_rewrite()

@run_until_complete
Expand Down Expand Up @@ -117,6 +121,8 @@ def test_info(self):
pass

@run_until_complete
@unittest.skipIf(REDIS_VERSION < (2, 8, 12),
'ROLE is available since redis>=2.8.12')
def test_role(self):
res = yield from self.redis.role()
self.assertEqual(dict(res._asdict()), {
Expand Down

0 comments on commit adb1794

Please sign in to comment.