+
+
+@pytest.mark.parametrize("value,result",
+ [(x, True) for x in ('1', 'true', 'True', 'yes', 'YES')] +
+ [(x, False) for x in ('0', 'false', 'no', 'NO', 'x')])
+def test_get_bool(make_config, monkeypatch, value, result):
+ config = make_config()
+
+ monkeypatch.setenv('NOMINATIM_FOOBAR', value)
+
+ assert config.get_bool('FOOBAR') == result
+
+def test_get_bool_empty(make_config):
+ config = make_config()
+
+ assert config.DATABASE_MODULE_PATH == ''
+ assert not config.get_bool('DATABASE_MODULE_PATH')
+
+
+@pytest.mark.parametrize("value,result", [('0', 0), ('1', 1),
+ ('85762513444', 85762513444)])
+def test_get_int_success(make_config, monkeypatch, value, result):
+ config = make_config()
+
+ monkeypatch.setenv('NOMINATIM_FOOBAR', value)
+
+ assert config.get_int('FOOBAR') == result
+
+
+@pytest.mark.parametrize("value", ['1b', 'fg', '0x23'])
+def test_get_int_bad_values(make_config, monkeypatch, value):
+ config = make_config()
+
+ monkeypatch.setenv('NOMINATIM_FOOBAR', value)
+
+ with pytest.raises(UsageError):
+ config.get_int('FOOBAR')
+
+
+def test_get_int_empty(make_config):
+ config = make_config()
+
+ assert config.DATABASE_MODULE_PATH == ''
+
+ with pytest.raises(UsageError):
+ config.get_int('DATABASE_MODULE_PATH')
+
+
+def test_get_import_style_intern(make_config, src_dir, monkeypatch):
+ config = make_config()
+
+ monkeypatch.setenv('NOMINATIM_IMPORT_STYLE', 'street')
+
+ expected = src_dir / 'settings' / 'import-street.style'
+
+ assert config.get_import_style_file() == expected
+
+
+@pytest.mark.parametrize("value", ['custom', '/foo/bar.stye'])
+def test_get_import_style_extern(make_config, monkeypatch, value):
+ config = make_config()
+
+ monkeypatch.setenv('NOMINATIM_IMPORT_STYLE', value)
+
+ assert str(config.get_import_style_file()) == value