Adds support for database number specification

This commit is contained in:
Trenton H
2022-12-02 13:54:15 -08:00
parent 3a6345f607
commit ce82c64fe0
2 changed files with 30 additions and 2 deletions

View File

@@ -97,7 +97,9 @@ class TestIgnoreDateParsing(TestCase):
"""
for input, expected in [
# Nothing is set
(None, ("redis://localhost:6379", "redis://localhost:6379")),
# celery style
(
"redis+socket:///run/redis/redis.sock",
(
@@ -105,6 +107,7 @@ class TestIgnoreDateParsing(TestCase):
"unix:///run/redis/redis.sock",
),
),
# redis-py / channels-redis style
(
"unix:///run/redis/redis.sock",
(
@@ -112,6 +115,22 @@ class TestIgnoreDateParsing(TestCase):
"unix:///run/redis/redis.sock",
),
),
# celery style with db
(
"redis+socket:///run/redis/redis.sock?virtual_host=5",
(
"redis+socket:///run/redis/redis.sock?virtual_host=5",
"unix:///run/redis/redis.sock?db=5",
),
),
# redis-py / channels-redis style with db
(
"unix:///run/redis/redis.sock?db=10",
(
"redis+socket:///run/redis/redis.sock?virtual_host=10",
"unix:///run/redis/redis.sock?db=10",
),
),
]:
result = _parse_redis_url(input)
self.assertTupleEqual(expected, result)