import itertools
import sys
-import tempfile
from pathlib import Path
import psycopg2
from nominatim.db.sql_preprocessor import SQLPreprocessor
from nominatim.db import properties
import nominatim.tokenizer.factory
+import nominatim.cli
import dummy_tokenizer
import mocks
@pytest.fixture
def table_factory(temp_db_cursor):
+ """ A fixture that creates new SQL tables, potentially filled with
+ content.
+ """
def mk_table(name, definition='id INT', content=None):
temp_db_cursor.execute('CREATE TABLE {} ({})'.format(name, definition))
if content is not None:
data=SRC_DIR / 'data')
return cfg
+
@pytest.fixture
def src_dir():
return SRC_DIR.resolve()
+
@pytest.fixture
-def tmp_phplib_dir():
- with tempfile.TemporaryDirectory() as phpdir:
- (Path(phpdir) / 'admin').mkdir()
+def cli_call():
+ def _call_nominatim(*args):
+ return nominatim.cli.nominatim(
+ module_dir='MODULE NOT AVAILABLE',
+ osm2pgsql_path='OSM2PGSQL NOT AVAILABLE',
+ phplib_dir=str(SRC_DIR / 'lib-php'),
+ data_dir=str(SRC_DIR / 'data'),
+ phpcgi_path='/usr/bin/php-cgi',
+ sqllib_dir=str(SRC_DIR / 'lib-sql'),
+ config_dir=str(SRC_DIR / 'settings'),
+ cli_args=args)
- yield Path(phpdir)
+ return _call_nominatim
@pytest.fixture
def property_table(table_factory):
table_factory('nominatim_properties', 'property TEXT, value TEXT')
+
@pytest.fixture
def status_table(temp_db_conn):
""" Create an empty version of the status table and