def test_get_experiment_invalid_experiment_id(mocker): mock_client = mocker.Mock() mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(ValueError): store.get_experiment("invalid-experiment-id")
def test_get_experiment_client_error(mocker): mock_client = mocker.Mock() mock_client.get.side_effect = HttpError( mocker.Mock(), "Experiment with ID _ not found in project _") mocker.patch("faculty.client", return_value=mock_client) store = FacultyRestStore(STORE_URI) with pytest.raises(MlflowException, match="Experiment with ID _ not found in project _"): store.get_experiment(EXPERIMENT_ID)
def test_get_experiment(mocker): faculty_experiment = mocker.Mock() mock_client = mocker.Mock() mock_client.get.return_value = faculty_experiment mocker.patch("faculty.client", return_value=mock_client) mlflow_experiment = mocker.Mock() converter = mocker.patch( "mlflow_faculty.tracking.faculty_experiment_to_mlflow_experiment", return_value=mlflow_experiment, ) store = FacultyRestStore(STORE_URI) experiment = store.get_experiment(EXPERIMENT_ID) mock_client.get.assert_called_once_with(PROJECT_ID, EXPERIMENT_ID) converter.assert_called_once_with(faculty_experiment) assert experiment == mlflow_experiment