Exemple #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(), mocker.Mock())
    with pytest.raises(ExperimentNameConflict,
                       match="name 'experiment name' already exists"):
        client.create(PROJECT_ID, "experiment name")
Exemple #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._ExperimentSchema")

    client = ExperimentClient(mocker.Mock(), 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,
        },
    )