Skip to content

Commit

Permalink
Use correct redis connection (#7077)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagogds authored Oct 24, 2024
1 parent 04a25f4 commit ee35912
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion redash/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_status():


def rq_job_ids():
queues = Queue.all(connection=redis_connection)
queues = Queue.all(connection=rq_redis_connection)

started_jobs = [StartedJobRegistry(queue=q).get_job_ids() for q in queues]
queued_jobs = [q.job_ids for q in queues]
Expand Down
23 changes: 23 additions & 0 deletions tests/test_monitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from unittest.mock import MagicMock, patch

from redash import rq_redis_connection
from redash.monitor import rq_job_ids


def test_rq_job_ids_uses_rq_redis_connection():
mock_queue = MagicMock()
mock_queue.job_ids = []

mock_registry = MagicMock()
mock_registry.get_job_ids.return_value = []

with patch("redash.monitor.Queue") as mock_Queue, patch(
"redash.monitor.StartedJobRegistry"
) as mock_StartedJobRegistry:
mock_Queue.all.return_value = [mock_queue]
mock_StartedJobRegistry.return_value = mock_registry

rq_job_ids()

mock_Queue.all.assert_called_once_with(connection=rq_redis_connection)
mock_StartedJobRegistry.assert_called_once_with(queue=mock_queue)

0 comments on commit ee35912

Please sign in to comment.