Пример #1
0
def test_model_modelapi_legal_resource_combinations(load_model_mock, api_mock,
                                                    raml, app):
    """Should allow between 0 and 3 resources, with 0 or 1 of each resource type."""
    with mock.patch(
            "ramlfications.parse",
            autospec=True,
            side_effect=lambda _: parsed_raml(raml),
    ):
        _ = api.ModelApi(minimal_config, app)
    api_mock.assert_called_once()
    load_model_mock.assert_called_once_with(minimal_config["model"])
Пример #2
0
def test_model_modelapi_predict_using_model(load_model_mock, api_mock,
                                            raml_mock, app):
    """Should return expected output."""
    a = api.ModelApi(minimal_config, app)
    output = a.predict_using_model({"a": [1, 2, 3]})
    assert output == prediction_output
Пример #3
0
def test_model_modelapi_malformed_version(load_model_mock, api_mock, raml_mock,
                                          app):
    """Should raise error if RAML version does not contain of three integers separated by dots ("0.11.22")."""
    with pytest.raises(ValueError, match="malformed"):
        _ = api.ModelApi(minimal_config_bad_version, app)
Пример #4
0
def test_model_modelapi_version_mismatch(load_model_mock, api_mock, raml_mock,
                                         app):
    """Should raise error if RAML version does not match major version in config."""
    with pytest.raises(ValueError, match="does not match API version"):
        _ = api.ModelApi(minimal_config, app)