def test_get_job_status_queued(client, job_id, mocker, mock_redis):
    queued = models.JobStatus(
        status="queued",
        last_change=dt.datetime(2021, 12, 11, 20, tzinfo=dt.timezone.utc),
    )
    mocker.patch(
        "solarperformanceinsight_api.storage.StorageInterface.get_job_status",
        return_value=queued,
    )
    response = client.get(f"/jobs/{job_id}/status")
    assert response.status_code == 200
    assert models.JobStatus(**response.json()) == queued
Beispiel #2
0
def test_get_job_status_running(client, job_id, mocker):
    running = models.JobStatus(
        status="running",
        last_change=dt.datetime(2021, 12, 11, 20, tzinfo=dt.timezone.utc),
    )
    mocker.patch(
        "solarperformanceinsight_api.storage.StorageInterface.get_job_status",
        return_value=models.JobStatus(status="queued", last_change=running.last_change),
    )
    mocker.patch(
        "solarperformanceinsight_api.queuing.QueueManager.job_status",
        return_value=running,
    )
    response = client.get(f"/jobs/{job_id}/status")
    assert response.status_code == 200
    assert models.JobStatus(**response.json()) == running
def test_get_job_status(client, job_id, job_status):
    response = client.get(f"/jobs/{job_id}/status")
    assert response.status_code == 200
    assert models.JobStatus(**response.json()) == job_status
def job_status():
    return models.JobStatus(
        status="incomplete",
        last_change=dt.datetime(2020, 12, 11, 20, tzinfo=dt.timezone.utc),
    )