示例#1
0
def test_get_job_status_raises_exception_when_job_cannot_be_found(
    mock_k8s_batch_api: MagicMock,
    batch_stage_job_object: kubernetes.client.V1Job
):
    mock_k8s_batch_api().list_namespaced_job.return_value = (
        kubernetes.client.V1JobList(items=[])
    )
    with raises(RuntimeError, match='cannot find job'):
        _get_job_status(batch_stage_job_object)
示例#2
0
def test_get_job_status_raises_exception_when_status_cannot_be_determined(
    mock_k8s_batch_api: MagicMock,
    batch_stage_job_object: kubernetes.client.V1Job
):
    mock_k8s_batch_api().list_namespaced_job.return_value = (
        kubernetes.client.V1JobList(
            items=[
                kubernetes.client.V1Job(
                    status=kubernetes.client.V1JobStatus(active='maybe')
                )
            ]
        )
    )
    with raises(RuntimeError, match='cannot determine status'):
        _get_job_status(batch_stage_job_object)
示例#3
0
def test_get_job_status_correctly_determines_failed_status(
    mock_k8s_batch_api: MagicMock,
    batch_stage_job_object: kubernetes.client.V1Job
):
    mock_k8s_batch_api().list_namespaced_job.return_value = (
        kubernetes.client.V1JobList(
            items=[
                kubernetes.client.V1Job(
                    status=kubernetes.client.V1JobStatus(failed=1)
                )
            ]
        )
    )
    assert _get_job_status(batch_stage_job_object) == JobStatus.FAILED