RQ background jobs tested with fakeredis: working versions (tested 2026-10-15)
Enqueue Redis Queue (RQ) jobs and process them with a SimpleWorker against fakeredis, so queue tests run offline with no Redis server.
passed2 passed · 0 failed2026-10-15 13:11 UTC- Status
- passed
- Last passed
- 2026-10-15 13:11 UTC
- Tests
- 2 / 2
- Language
- Python
- Runtime
- Python 3.13.16
pinned versions3
rq@2.12.0fakeredis@2.40.0pytest@9.1.1
run it
uv venv -q .venv && uv pip install -q --python .venv/bin/python -r requirements.txt .venv/bin/python -m pytest -q
test environment
Python 3.13.16 linux 6.17.0-1022-azure x64 runner: github-actions 38738874208
The code
Exactly the files that passed. Your agent can pull them with get_recipe("rq-fakeredis-jobs") (install), or see them on GitHub.
requirements.txt
rq==2.12.0 fakeredis==2.40.0 pytest==9.1.1
jobs.py
def send_welcome_email(address: str) -> str:
# replace with your real mailer
return f"sent to {address}"
def explode():
raise RuntimeError("boom")
tests/test_jobs.py
import pytest
from fakeredis import FakeStrictRedis
from rq import Queue, SimpleWorker
from rq.job import JobStatus
from jobs import send_welcome_email, explode
@pytest.fixture
def queue():
return Queue("default", connection=FakeStrictRedis())
def test_job_runs(queue):
job = queue.enqueue(send_welcome_email, "[email protected]")
assert job.get_status() == JobStatus.QUEUED
SimpleWorker([queue], connection=queue.connection).work(burst=True)
job.refresh()
assert job.get_status() == JobStatus.FINISHED
assert job.return_value() == "sent to [email protected]"
def test_failed_job_lands_in_registry(queue):
job = queue.enqueue(explode)
SimpleWorker([queue], connection=queue.connection).work(burst=True)
job.refresh()
assert job.get_status() == JobStatus.FAILED
assert job.id in queue.failed_job_registry.get_job_ids()
pytest.ini
[pytest] pythonpath = .
Connect to ProvenPin
Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.
terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp
~/.cursor/mcp.json
{ "mcpServers": { "provenpin": { "url": "https://mcp.provenpin.com/mcp" } } }.vscode/mcp.json
{ "servers": { "provenpin": { "type": "http", "url": "https://mcp.provenpin.com/mcp" } } }~/.codeium/windsurf/mcp_config.json
{ "mcpServers": { "provenpin": { "serverUrl": "https://mcp.provenpin.com/mcp" } } }MCP settings
{ "mcpServers": { "provenpin": { "type": "streamableHttp", "url": "https://mcp.provenpin.com/mcp" } } }Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.