mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
bdd tests: directly call python code for setup-website
This commit is contained in:
@@ -17,7 +17,7 @@ class Configuration:
|
|||||||
Nominatim uses dotenv to configure the software. Configuration options
|
Nominatim uses dotenv to configure the software. Configuration options
|
||||||
are resolved in the following order:
|
are resolved in the following order:
|
||||||
|
|
||||||
* from the OS environment
|
* from the OS environment (or the dirctionary given in `environ`
|
||||||
* from the .env file in the project directory of the installation
|
* from the .env file in the project directory of the installation
|
||||||
* from the default installation in the configuration directory
|
* from the default installation in the configuration directory
|
||||||
|
|
||||||
@@ -25,7 +25,8 @@ class Configuration:
|
|||||||
avoid conflicts with other environment variables.
|
avoid conflicts with other environment variables.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, project_dir, config_dir):
|
def __init__(self, project_dir, config_dir, environ=os.environ):
|
||||||
|
self.environ = environ
|
||||||
self.project_dir = project_dir
|
self.project_dir = project_dir
|
||||||
self.config_dir = config_dir
|
self.config_dir = config_dir
|
||||||
self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
|
self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
|
||||||
@@ -42,7 +43,7 @@ class Configuration:
|
|||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
name = 'NOMINATIM_' + name
|
name = 'NOMINATIM_' + name
|
||||||
|
|
||||||
return os.environ.get(name) or self._config[name]
|
return self.environ.get(name) or self._config[name]
|
||||||
|
|
||||||
def get_bool(self, name):
|
def get_bool(self, name):
|
||||||
""" Return the given configuration parameter as a boolean.
|
""" Return the given configuration parameter as a boolean.
|
||||||
@@ -100,6 +101,6 @@ class Configuration:
|
|||||||
merged in.
|
merged in.
|
||||||
"""
|
"""
|
||||||
env = dict(self._config)
|
env = dict(self._config)
|
||||||
env.update(os.environ)
|
env.update(self.environ)
|
||||||
|
|
||||||
return env
|
return env
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import psycopg2.extras
|
|||||||
sys.path.insert(1, str((Path(__file__) / '..' / '..' / '..' / '..').resolve()))
|
sys.path.insert(1, str((Path(__file__) / '..' / '..' / '..' / '..').resolve()))
|
||||||
|
|
||||||
from nominatim.config import Configuration
|
from nominatim.config import Configuration
|
||||||
|
from nominatim.tools import refresh
|
||||||
from steps.utils import run_script
|
from steps.utils import run_script
|
||||||
|
|
||||||
class NominatimEnvironment:
|
class NominatimEnvironment:
|
||||||
@@ -104,7 +105,8 @@ class NominatimEnvironment:
|
|||||||
self.website_dir.cleanup()
|
self.website_dir.cleanup()
|
||||||
|
|
||||||
self.website_dir = tempfile.TemporaryDirectory()
|
self.website_dir = tempfile.TemporaryDirectory()
|
||||||
self.run_setup_script('setup-website')
|
cfg = Configuration(None, self.src_dir / 'settings', environ=self.test_env)
|
||||||
|
refresh.setup_website(Path(self.website_dir.name) / 'website', self.src_dir / 'lib-php', cfg)
|
||||||
|
|
||||||
|
|
||||||
def db_drop_database(self, name):
|
def db_drop_database(self, name):
|
||||||
|
|||||||
Reference in New Issue
Block a user