Browse Source

more unit tests

pull/1448/head
Miguel Grinberg 6 days ago
parent
commit
4e701453cf
Failed to extract signature
  1. 7
      src/socketio/redis_manager.py
  2. 18
      tests/common/test_redis_manager.py

7
src/socketio/redis_manager.py

@ -29,15 +29,12 @@ def parse_redis_sentinel_url(url):
kwargs['username'] = parsed_url.username
if parsed_url.password:
kwargs['password'] = parsed_url.password
if parsed_url.query:
for key, value in urlparse.parse_qs(parsed_url.query).items():
kwargs[key] = value[0]
service_name = None
if parsed_url.path:
parts = parsed_url.path.split('/')
if len(parts) >= 2:
if len(parts) >= 2 and parts[1] != '':
kwargs['db'] = int(parts[1])
if len(parts) >= 3:
if len(parts) >= 3 and parts[2] != '':
service_name = parts[2]
return sentinels, service_name, kwargs

18
tests/common/test_redis_manager.py

@ -9,12 +9,26 @@ class TestPubSubManager:
parse_redis_sentinel_url('redis://localhost:6379/0')
assert parse_redis_sentinel_url(
'redis+sentinel://h1:6379,h2:6379'
'redis+sentinel://localhost:6379'
) == (
[('h1', 6379), ('h2', 6379)],
[('localhost', 6379)],
None,
{}
)
assert parse_redis_sentinel_url(
'redis+sentinel://192.168.0.1:6379,192.168.0.2:6379/'
) == (
[('192.168.0.1', 6379), ('192.168.0.2', 6379)],
None,
{}
)
assert parse_redis_sentinel_url(
'redis+sentinel://h1:6379,h2:6379/0'
) == (
[('h1', 6379), ('h2', 6379)],
None,
{'db': 0}
)
assert parse_redis_sentinel_url(
'redis+sentinel://user:password@h1:6379,h2:6379,h1:6380/0/myredis'
) == (

Loading…
Cancel
Save