forked from hans/Nominatim
restrict use of os.environ in Configuration
Only use the OS environment, when the environ parameter is set to None. Currently it would use the OS env on an empty dict.
This commit is contained in:
@@ -61,7 +61,7 @@ class Configuration:
|
|||||||
|
|
||||||
def __init__(self, project_dir: Optional[Union[Path, str]],
|
def __init__(self, project_dir: Optional[Union[Path, str]],
|
||||||
environ: Optional[Mapping[str, str]] = None) -> None:
|
environ: Optional[Mapping[str, str]] = None) -> None:
|
||||||
self.environ = environ or os.environ
|
self.environ = os.environ if environ is None else environ
|
||||||
self.config_dir = paths.CONFIG_DIR
|
self.config_dir = paths.CONFIG_DIR
|
||||||
self._config = dotenv_values(str(self.config_dir / 'env.defaults'))
|
self._config = dotenv_values(str(self.config_dir / 'env.defaults'))
|
||||||
if project_dir is not None:
|
if project_dir is not None:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ async def conn(table_factory):
|
|||||||
table_factory('word',
|
table_factory('word',
|
||||||
definition='word_id INT, word_token TEXT, type TEXT, word TEXT, info JSONB')
|
definition='word_id INT, word_token TEXT, type TEXT, word TEXT, info JSONB')
|
||||||
|
|
||||||
async with NominatimAPIAsync(environ={}) as api:
|
async with NominatimAPIAsync() as api:
|
||||||
async with api.begin() as conn:
|
async with api.begin() as conn:
|
||||||
yield conn
|
yield conn
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ async def conn(table_factory, temp_db_cursor):
|
|||||||
temp_db_cursor.execute("""CREATE OR REPLACE FUNCTION make_standard_name(name TEXT)
|
temp_db_cursor.execute("""CREATE OR REPLACE FUNCTION make_standard_name(name TEXT)
|
||||||
RETURNS TEXT AS $$ SELECT lower(name); $$ LANGUAGE SQL;""")
|
RETURNS TEXT AS $$ SELECT lower(name); $$ LANGUAGE SQL;""")
|
||||||
|
|
||||||
async with NominatimAPIAsync(environ={}) as api:
|
async with NominatimAPIAsync() as api:
|
||||||
async with api.begin() as conn:
|
async with api.begin() as conn:
|
||||||
yield conn
|
yield conn
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def test_status_full(apiobj, frontend):
|
|||||||
def test_status_database_not_found(monkeypatch):
|
def test_status_database_not_found(monkeypatch):
|
||||||
monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg')
|
monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg')
|
||||||
|
|
||||||
api = napi.NominatimAPI(environ={})
|
api = napi.NominatimAPI()
|
||||||
|
|
||||||
result = api.status()
|
result = api.status()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user