]> git.openstreetmap.org Git - nominatim.git/commitdiff
bdd: recreate functions on template DB
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 11 May 2022 13:50:22 +0000 (15:50 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 11 May 2022 13:50:22 +0000 (15:50 +0200)
Avoids calling function refresh on every scenario. The content won't
change between runs.

test/bdd/steps/nominatim_environment.py
test/bdd/steps/steps_db_ops.py

index 9bf182bc1fe408f866441f776560b6288d7f8bbb..c1a7dc2677eca95ea39d37e9477fd75d30bb924b 100644 (file)
@@ -172,23 +172,23 @@ class NominatimEnvironment:
 
         self.template_db_done = True
 
-        if self._reuse_or_drop_db(self.template_db):
-            return
-
         self.write_nominatim_config(self.template_db)
 
-        try:
-            # execute nominatim import on an empty file to get the right tables
-            with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.xml') as fd:
-                fd.write(b'<osm version="0.6"></osm>')
-                fd.flush()
-                self.run_nominatim('import', '--osm-file', fd.name,
-                                             '--osm2pgsql-cache', '1',
-                                             '--ignore-errors',
-                                             '--offline', '--index-noanalyse')
-        except:
-            self.db_drop_database(self.template_db)
-            raise
+        if not self._reuse_or_drop_db(self.template_db):
+            try:
+                # execute nominatim import on an empty file to get the right tables
+                with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.xml') as fd:
+                    fd.write(b'<osm version="0.6"></osm>')
+                    fd.flush()
+                    self.run_nominatim('import', '--osm-file', fd.name,
+                                                 '--osm2pgsql-cache', '1',
+                                                 '--ignore-errors',
+                                                 '--offline', '--index-noanalyse')
+            except:
+                self.db_drop_database(self.template_db)
+                raise
+
+        self.run_nominatim('refresh', '--functions')
 
 
     def setup_api_db(self):
index 5ce416b013678a741f064cbbe2b19d30040e4b42..63c5120e88a894c99970a218a7b864fe48f1055d 100644 (file)
@@ -93,7 +93,6 @@ def add_data_to_planet_ways(context):
 def import_and_index_data_from_place_table(context):
     """ Import data previously set up in the place table.
     """
-    context.nominatim.run_nominatim('refresh', '--functions')
     context.nominatim.run_nominatim('import', '--continue', 'load-data',
                                               '--index-noanalyse', '-q',
                                               '--offline')