Example #1
0
def test_experiment_client_list(mocker):
    experiment = mocker.Mock()
    mocker.patch.object(ExperimentClient, "_get", return_value=[experiment])
    schema_mock = mocker.patch("faculty.clients.experiment._ExperimentSchema")

    client = ExperimentClient(mocker.Mock(), mocker.Mock())
    assert client.list(PROJECT_ID) == [experiment]

    schema_mock.assert_called_once_with(many=True)
    ExperimentClient._get.assert_called_once_with(
        "/project/{}/experiment".format(PROJECT_ID),
        schema_mock.return_value,
        params={},
    )
Example #2
0
def test_experiment_client_list_lifecycle_filter(mocker):
    experiment = mocker.Mock()
    mocker.patch.object(ExperimentClient, "_get", return_value=[experiment])
    schema_mock = mocker.patch("faculty.clients.experiment._ExperimentSchema")

    client = ExperimentClient(mocker.Mock(), mocker.Mock())
    returned_experiments = client.list(PROJECT_ID,
                                       lifecycle_stage=LifecycleStage.ACTIVE)
    assert returned_experiments == [experiment]

    schema_mock.assert_called_once_with(many=True)
    ExperimentClient._get.assert_called_once_with(
        "/project/{}/experiment".format(PROJECT_ID),
        schema_mock.return_value,
        params={"lifecycleStage": "active"},
    )