Exemple #1
0
def test_get_run_throws_when_get_object_fails(mocker):
    run_name = "test_run_wibble"

    mock = mocker.Mock()
    mock.get_namespaced_custom_object = mocker.Mock()
    mock.get_namespaced_custom_object.side_effect = ApiException(
        "doesn't exist")

    db_run_client = DbRunClient(mock)

    with pytest.raises(InterruptTaskSet):
        db_run_client.get_run(run_name)
Exemple #2
0
def test_get_run(mocker):
    run_name = "test_run_wibble"

    mock = mocker.Mock()
    mock.get_namespaced_custom_object = mocker.Mock()
    mock.get_namespaced_custom_object.return_value = {"name": run_name}

    db_run_client = DbRunClient(mock)
    result = db_run_client.get_run(run_name)

    mock.get_namespaced_custom_object.assert_called_once_with(
        group=K8_GROUP,
        version=VERSION,
        namespace="default",
        plural="runs",
        name=run_name,
    )

    assert result == {"name": run_name}