MockArqQueue#
- class safir.arq.MockArqQueue(*, default_queue_name='arq:queue')#
Bases:
ArqQueue
A mocked queue for testing API services.
- Parameters:
default_queue_name (
str
, default:'arq:queue'
) –
Methods Summary
enqueue
(task_name, *task_args[, _queue_name])Add a job to the queue.
get_job_metadata
(job_id[, queue_name])Get metadata about a ~arq.jobs.Job.
get_job_result
(job_id[, queue_name])Retrieve the job result, if available.
set_complete
(job_id, *, result[, success, ...])Set a job's result, for mocking a queue in tests.
set_in_progress
(job_id[, queue_name])Set a job's status to in progress, for mocking a queue in tests.
Methods Documentation
- async enqueue(task_name, *task_args, _queue_name=None, **task_kwargs)#
Add a job to the queue.
- Parameters:
- Returns:
Metadata about the queued job.
- Return type:
- Raises:
JobNotQueued – Raised if the job is not successfully added to the queue.
- async get_job_metadata(job_id, queue_name=None)#
Get metadata about a ~arq.jobs.Job.
- Parameters:
- Returns:
Metadata about the queued job.
- Return type:
- Raises:
JobNotFound – Raised if the job is not found in the queue.
- async get_job_result(job_id, queue_name=None)#
Retrieve the job result, if available.
- Parameters:
- Returns:
The job’s result, along with metadata about the queued job.
- Return type:
- Raises:
JobNotFound – Raised if the job is not found in the queue.
JobResultUnavailable – Raised if the job’s result is unavailable for any reason.
- async set_complete(job_id, *, result, success=True, queue_name=None)#
Set a job’s result, for mocking a queue in tests.