Ejemplo n.º 1
0
def test_experiment_client_create_name_conflict(mocker):
    error_code = "experiment_name_conflict"
    exception = Conflict(mocker.Mock(), mocker.Mock(), error_code)
    mocker.patch.object(ExperimentClient, "_post", side_effect=exception)

    client = ExperimentClient(mocker.Mock())
    with pytest.raises(
        ExperimentNameConflict, match="name 'experiment name' already exists"
    ):
        client.create(PROJECT_ID, "experiment name")
Ejemplo n.º 2
0
def test_experiment_client_create(mocker, description, artifact_location):
    experiment = mocker.Mock()
    mocker.patch.object(ExperimentClient, "_post", return_value=experiment)
    schema_mock = mocker.patch(
        "faculty.clients.experiment._client.ExperimentSchema"
    )

    client = ExperimentClient(mocker.Mock())
    returned_experiment = client.create(
        PROJECT_ID, "experiment name", description, artifact_location
    )
    assert returned_experiment == experiment

    schema_mock.assert_called_once_with()
    ExperimentClient._post.assert_called_once_with(
        "/project/{}/experiment".format(PROJECT_ID),
        schema_mock.return_value,
        json={
            "name": "experiment name",
            "description": description,
            "artifactLocation": artifact_location,
        },
    )