]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/conftest.py
test: avoid use of tempfile module
[nominatim.git] / test / python / conftest.py
index 969a6aaac25136401eb1947f17695f85ad462a61..c25449486546fa318e918b4000efbc8f9dec81e1 100644 (file)
@@ -1,6 +1,5 @@
 import itertools
 import sys
-import tempfile
 from pathlib import Path
 
 import psycopg2
@@ -16,6 +15,7 @@ from nominatim.db import connection
 from nominatim.db.sql_preprocessor import SQLPreprocessor
 from nominatim.db import properties
 import nominatim.tokenizer.factory
+import nominatim.cli
 
 import dummy_tokenizer
 import mocks
@@ -87,6 +87,9 @@ def temp_db_cursor(temp_db):
 
 @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:
@@ -104,22 +107,33 @@ def def_config():
                     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