|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 |
|
| 16 | +from unittest.mock import patch |
| 17 | + |
16 | 18 | import pytest
|
17 | 19 | import redis
|
18 | 20 |
|
|
21 | 23 | DABRedisCluster,
|
22 | 24 | DefaultWorker,
|
23 | 25 | Queue,
|
| 26 | + _create_url_from_parameters, |
24 | 27 | get_redis_client,
|
25 | 28 | logger,
|
26 | 29 | unique_enqueue,
|
@@ -66,6 +69,36 @@ def test_unique_enqueue_new_job(default_queue, eda_caplog):
|
66 | 69 | assert "Enqueing unique job" in eda_caplog.text
|
67 | 70 |
|
68 | 71 |
|
| 72 | +@patch("aap_eda.settings.default.REDIS_UNIX_SOCKET_PATH", "path/to/socket") |
| 73 | +def test_unix_dab_url(): |
| 74 | + url = _create_url_from_parameters( |
| 75 | + **default.rq_redis_client_instantiation_parameters() |
| 76 | + ) |
| 77 | + assert url == "unix://path/to/socket" |
| 78 | + |
| 79 | + |
| 80 | +@patch("aap_eda.settings.default.REDIS_UNIX_SOCKET_PATH", None) |
| 81 | +@patch("aap_eda.settings.default.REDIS_CLIENT_CERT_PATH", None) |
| 82 | +@patch("aap_eda.settings.default.REDIS_HOST", "a-host") |
| 83 | +@patch("aap_eda.settings.default.REDIS_PORT", 6379) |
| 84 | +def test_redis_dab_url(): |
| 85 | + url = _create_url_from_parameters( |
| 86 | + **default.rq_redis_client_instantiation_parameters() |
| 87 | + ) |
| 88 | + assert url == "redis://a-host:6379" |
| 89 | + |
| 90 | + |
| 91 | +@patch("aap_eda.settings.default.REDIS_UNIX_SOCKET_PATH", None) |
| 92 | +@patch("aap_eda.settings.default.REDIS_CLIENT_CERT_PATH", "path/to/cert") |
| 93 | +@patch("aap_eda.settings.default.REDIS_HOST", "a-different-host") |
| 94 | +@patch("aap_eda.settings.default.REDIS_PORT", 6380) |
| 95 | +def test_rediss_dab_url(): |
| 96 | + url = _create_url_from_parameters( |
| 97 | + **default.rq_redis_client_instantiation_parameters() |
| 98 | + ) |
| 99 | + assert url == "rediss://a-different-host:6380" |
| 100 | + |
| 101 | + |
69 | 102 | def test_worker_dab_client(default_queue: Queue):
|
70 | 103 | """Test that workers end up with a DABRedis client connection."""
|
71 | 104 |
|
|
0 commit comments