This removes the dependency on php-symfony-dotenv for the tests.
- name: Install test prerequsites
run: |
- name: Install test prerequsites
run: |
- sudo apt-get install -y -qq php-codesniffer python3-tidylib php-symfony-dotenv
+ sudo apt-get install -y -qq php-codesniffer
sudo pip3 install behave
- name: PHP linting
sudo pip3 install behave
- name: PHP linting
def __init__(self, project_dir, config_dir):
self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
def __init__(self, project_dir, config_dir):
self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
- self._config.update(dotenv_values(str((project_dir / '.env').resolve())))
+ if project_dir is not None:
+ self._config.update(dotenv_values(str((project_dir / '.env').resolve())))
def __getattr__(self, name):
name = 'NOMINATIM_' + name
def __getattr__(self, name):
name = 'NOMINATIM_' + name
from steps.geometry_factory import GeometryFactory
from steps.nominatim_environment import NominatimEnvironment
from steps.geometry_factory import GeometryFactory
from steps.nominatim_environment import NominatimEnvironment
import tempfile
import psycopg2
import psycopg2.extras
import tempfile
import psycopg2
import psycopg2.extras
+sys.path.insert(1, str((Path(__file__) / '..' / '..' / '..' / '..').resolve()))
+
+from nominatim.config import Configuration
from steps.utils import run_script
class NominatimEnvironment:
from steps.utils import run_script
class NominatimEnvironment:
self.code_coverage_path = config['PHPCOV']
self.code_coverage_id = 1
self.code_coverage_path = config['PHPCOV']
self.code_coverage_id = 1
+ self.default_config = Configuration(None, self.src_dir / 'settings').get_os_env()
self.test_env = None
self.template_db_done = False
self.api_db_done = False
self.test_env = None
self.template_db_done = False
self.api_db_done = False
and dsn == self.test_env['NOMINATIM_DATABASE_DSN']:
return # environment already set uo
and dsn == self.test_env['NOMINATIM_DATABASE_DSN']:
return # environment already set uo
- self.test_env = os.environ
+ self.test_env = dict(self.default_config)
self.test_env['NOMINATIM_DATABASE_DSN'] = dsn
self.test_env['NOMINATIM_FLATNODE_FILE'] = ''
self.test_env['NOMINATIM_IMPORT_STYLE'] = 'full'
self.test_env['NOMINATIM_USE_US_TIGER_DATA'] = 'yes'
self.test_env['NOMINATIM_DATABASE_DSN'] = dsn
self.test_env['NOMINATIM_FLATNODE_FILE'] = ''
self.test_env['NOMINATIM_IMPORT_STYLE'] = 'full'
self.test_env['NOMINATIM_USE_US_TIGER_DATA'] = 'yes'
+ self.test_env['NOMINATIM_DATADIR'] = self.src_dir
+ self.test_env['NOMINATIM_BINDIR'] = self.src_dir / 'utils'
+ self.test_env['NOMINATIM_DATABASE_MODULE_PATH'] = self.build_dir / 'module'
+ self.test_env['NOMINATIM_OSM2PGSQL_BINARY'] = self.build_dir / 'osm2pgsql' / 'osm2pgsql'
if self.server_module_path:
self.test_env['NOMINATIM_DATABASE_MODULE_PATH'] = self.server_module_path
if self.server_module_path:
self.test_env['NOMINATIM_DATABASE_MODULE_PATH'] = self.server_module_path
""" Run one of the Nominatim utility scripts with the given arguments.
"""
cmd = ['/usr/bin/env', 'php', '-Cq']
""" Run one of the Nominatim utility scripts with the given arguments.
"""
cmd = ['/usr/bin/env', 'php', '-Cq']
- cmd.append((Path(self.build_dir) / 'utils' / '{}.php'.format(script)).resolve())
+ cmd.append((Path(self.src_dir) / 'lib' / 'admin' / '{}.php'.format(script)).resolve())
cmd.extend(['--' + x for x in args])
for k, v in kwargs.items():
cmd.extend(('--' + k.replace('_', '-'), str(v)))
cmd.extend(['--' + x for x in args])
for k, v in kwargs.items():
cmd.extend(('--' + k.replace('_', '-'), str(v)))
if self.website_dir is not None:
cwd = self.website_dir.name
else:
if self.website_dir is not None:
cwd = self.website_dir.name
else:
run_script(cmd, cwd=cwd, env=self.test_env)
run_script(cmd, cwd=cwd, env=self.test_env)
""" Query directly via PHP script.
"""
cmd = ['/usr/bin/env', 'php']
""" Query directly via PHP script.
"""
cmd = ['/usr/bin/env', 'php']
- cmd.append(os.path.join(context.nominatim.build_dir, 'utils', 'query.php'))
+ cmd.append(context.nominatim.src_dir / 'lib' / 'admin' / 'query.php')
if query:
cmd.extend(['--search', query])
# add more parameters in table form
if query:
cmd.extend(['--search', query])
# add more parameters in table form
if dups:
cmd.extend(('--dedupe', '0'))
if dups:
cmd.extend(('--dedupe', '0'))
- outp, err = run_script(cmd, cwd=context.nominatim.build_dir)
+ outp, err = run_script(cmd, cwd=context.nominatim.website_dir.name,
+ env=context.nominatim.test_env)
context.response = SearchResponse(outp, 'json')
context.response = SearchResponse(outp, 'json')