MockUWSJobRunner

class safir.testing.uws.MockUWSJobRunner(config, arq_queue)

Bases: object

Simulate execution of jobs with a mock queue.

When running the test suite, the arq queue is replaced with a mock queue that doesn’t execute workers. That execution has to be simulated by manually updating state in the mock queue and running the UWS database worker functions that normally would be run automatically by the queue.

This class wraps that functionality in an async context manager. An instance of it is normally provided as a fixture, initialized with the same test objects as the test suite.

Parameters:

Methods Summary

get_job_metadata(username, job_id)

Get the arq job metadata for a job.

get_job_result(username, job_id)

Get the arq job result for a job.

mark_complete(username, job_id, results, *)

Mark an in progress job as complete.

mark_in_progress(username, job_id, *[, delay])

Mark a queued job in progress.

Methods Documentation

async get_job_metadata(username, job_id)

Get the arq job metadata for a job.

Parameters:
  • job_id (str) – UWS job ID.

  • username (str)

Returns:

arq job metadata.

Return type:

JobMetadata

async get_job_result(username, job_id)

Get the arq job result for a job.

Parameters:
  • job_id (str) – UWS job ID.

  • username (str)

Returns:

arq job metadata.

Return type:

JobMetadata

async mark_complete(username, job_id, results, *, delay=None)

Mark an in progress job as complete.

Parameters:
  • username (str) – Owner of job.

  • job_id (str) – Job ID.

  • results (list[UWSJobResult] | Exception) – Results to return. May be an exception to simulate a job failure.

  • delay (float | None, default: None) – How long to delay in seconds before marking the job as complete.

Returns:

Record of the job.

Return type:

UWSJob

async mark_in_progress(username, job_id, *, delay=None)

Mark a queued job in progress.

Parameters:
  • username (str) – Owner of job.

  • job_id (str) – Job ID.

  • delay (float | None, default: None) – How long to delay in seconds before marking the job as complete.

Returns:

Record of the job.

Return type:

UWSJob