Ejemplo n.º 1
0
def test_create_physical_settings_resource(mock_create, model_ini):
    config = model_ini.as_dict()
    client = OpenAPIPhysicalSettings(1, config, SourceTypes.ini_file)

    mock_create.return_value = client.instance
    resp = client.create()
    assert resp == client.instance
Ejemplo n.º 2
0
def test_create_physical_settings_resource_error(mock_create, model_ini):
    config = model_ini.as_dict()
    client = OpenAPIPhysicalSettings(1, config, SourceTypes.ini_file)

    mock_create.side_effect = ApiException
    # create, side effect ApiExc, AttrErr
    with pytest.raises(ApiException):
        client.create()
Ejemplo n.º 3
0
def test_openapi_settings_clients(model_ini):
    # smoke tests
    config = model_ini.as_dict()
    clients = [
        OpenAPIPhysicalSettings(1, config, SourceTypes.ini_file),
        OpenAPINumericalSettings(1, config, SourceTypes.ini_file),
        OpenAPITimeStepSettings(1, config, SourceTypes.ini_file),
    ]
    for client in clients:
        assert isinstance(
            client.instance,
            (PhysicalSettings, TimeStepSettings, NumericalSettings))
Ejemplo n.º 4
0
def test_openapi__create_method_error(mock_create_method, model_ini):
    config = model_ini.as_dict()
    mock_create_method.return_value = "invalid"
    client = OpenAPITimeStepSettings(1, config, SourceTypes.ini_file)
    with pytest.raises(AttributeError):
        client._create_method()
Ejemplo n.º 5
0
def test_openapi__create_method_property(model_ini):
    config = model_ini.as_dict()
    client = OpenAPITimeStepSettings(1, config, SourceTypes.ini_file)
    assert callable(client._create_method)
Ejemplo n.º 6
0
def test_openapi_type_conversions(model_ini):
    config = model_ini.as_dict()
    client = OpenAPINumericalSettings(1, config, SourceTypes.ini_file)
    # should have a default from mapping
    assert client.instance.use_nested_newton is False
Ejemplo n.º 7
0
def test_openapi_defaults_from_mapping(model_ini):
    config = model_ini.as_dict()
    client = OpenAPINumericalSettings(1, config, SourceTypes.ini_file)
    # should have a default from mapping
    assert client.instance.friction_shallow_water_depth_correction == 0
Ejemplo n.º 8
0
def test_openapi_name_conversions(model_ini):
    config = model_ini.as_dict()
    client = OpenAPIPhysicalSettings(1, config, SourceTypes.ini_file)
    # should have attributes use_advection_2d/1d now
    assert client.instance.use_advection_2d == 0  # from ini
    assert client.instance.use_advection_1d == 0  # from ini
def tests_threedimodelini_as_dict_with_sections(model_ini):
    ini_dict = model_ini.as_dict(flat=False)
    # note: set of sections is not complete
    for x in {"meta", "physics", "physical_attributes", "grid_administration"}:
        assert x in set(ini_dict.keys())