async def test_deserialize_error(mocked_job_info: MagicMock, jobs_creator: JobsCreator) -> None: job = await jobs_creator.create_complete() mocked_job_info.side_effect = DeserializationError() queue = Queue.from_name(default_queue_name) job_info = await queue.get_job_by_id(job.job_id) assert job_info.function == "Unknown, can't deserialize"
async def _gather_queues() -> List[QueueStats]: tasks = [] for name in ARQ_QUEUES.keys(): queue = Queue.from_name(name) tasks.append(queue.get_stats()) return await asyncio.gather(*tasks)
async def test_stats(all_jobs: List[Job]) -> None: queue = Queue.from_name(default_queue_name) assert await queue.get_stats() == QueueStats( name=default_queue_name, host=settings.REDIS_SETTINGS.host, port=settings.REDIS_SETTINGS.port, database=settings.REDIS_SETTINGS.database, queued_jobs=1, complete_jobs=1, running_jobs=1, deferred_jobs=1, )
async def test_status_filter(all_jobs: List[Job]) -> None: queue = Queue.from_name(default_queue_name) assert len(await queue.get_jobs(JobStatus.deferred)) == 1 assert len(await queue.get_jobs(JobStatus.complete)) == 1 assert len(await queue.get_jobs(JobStatus.in_progress)) == 1 assert len(await queue.get_jobs(JobStatus.queued)) == 1
async def test_all_get_jobs(all_jobs: List[Job]) -> None: queue = Queue.from_name(default_queue_name) assert len(await queue.get_jobs()) == 4
def get_object(self, queryset: Optional[Any] = None) -> JobInfo: queue = Queue.from_name(self.kwargs['queue_name']) return asyncio.run(queue.get_job_by_id(self.kwargs['job_id']))
def get_queryset(self) -> List[JobInfo]: queue_name = self.kwargs['queue_name'] queue = Queue.from_name(queue_name) return sorted(asyncio.run(queue.get_jobs(status=self.status)), key=attrgetter('enqueue_time'))