]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/bdd/steps/nominatim_environment.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / bdd / steps / nominatim_environment.py
index 88a4f11c73ebc5ec135b0443660cce3f14753731..ba19bb48e4accd40e71b053d8eab052e3d8559bb 100644 (file)
@@ -34,11 +34,8 @@ class NominatimEnvironment:
         self.api_test_file = config['API_TEST_FILE']
         self.tokenizer = config['TOKENIZER']
         self.import_style = config['STYLE']
         self.api_test_file = config['API_TEST_FILE']
         self.tokenizer = config['TOKENIZER']
         self.import_style = config['STYLE']
-        self.server_module_path = config['SERVER_MODULE_PATH']
         self.reuse_template = not config['REMOVE_TEMPLATE']
         self.keep_scenario_db = config['KEEP_TEST_DB']
         self.reuse_template = not config['REMOVE_TEMPLATE']
         self.keep_scenario_db = config['KEEP_TEST_DB']
-        self.code_coverage_path = config['PHPCOV']
-        self.code_coverage_id = 1
 
         self.default_config = Configuration(None).get_os_env()
         self.test_env = None
 
         self.default_config = Configuration(None).get_os_env()
         self.test_env = None
@@ -46,14 +43,9 @@ class NominatimEnvironment:
         self.api_db_done = False
         self.website_dir = None
 
         self.api_db_done = False
         self.website_dir = None
 
-        self.api_engine = None
-        if config['API_ENGINE'] != 'php':
-            if not hasattr(self, f"create_api_request_func_{config['API_ENGINE']}"):
-                raise RuntimeError(f"Unknown API engine '{config['API_ENGINE']}'")
-            self.api_engine = getattr(self, f"create_api_request_func_{config['API_ENGINE']}")()
-
-        if self.tokenizer == 'legacy' and self.server_module_path is None:
-            raise RuntimeError("You must set -DSERVER_MODULE_PATH when testing the legacy tokenizer.")
+        if not hasattr(self, f"create_api_request_func_{config['API_ENGINE']}"):
+            raise RuntimeError(f"Unknown API engine '{config['API_ENGINE']}'")
+        self.api_engine = getattr(self, f"create_api_request_func_{config['API_ENGINE']}")()
 
     def connect_database(self, dbname):
         """ Return a connection to the database with the given name.
 
     def connect_database(self, dbname):
         """ Return a connection to the database with the given name.
@@ -70,13 +62,6 @@ class NominatimEnvironment:
             dbargs['password'] = self.db_pass
         return psycopg.connect(**dbargs)
 
             dbargs['password'] = self.db_pass
         return psycopg.connect(**dbargs)
 
-    def next_code_coverage_file(self):
-        """ Generate the next name for a coverage file.
-        """
-        fn = Path(self.code_coverage_path) / "{:06d}.cov".format(self.code_coverage_id)
-        self.code_coverage_id += 1
-
-        return fn.resolve()
 
     def write_nominatim_config(self, dbname):
         """ Set up a custom test configuration that connects to the given
 
     def write_nominatim_config(self, dbname):
         """ Set up a custom test configuration that connects to the given
@@ -111,27 +96,14 @@ class NominatimEnvironment:
         if self.import_style is not None:
             self.test_env['NOMINATIM_IMPORT_STYLE'] = self.import_style
 
         if self.import_style is not None:
             self.test_env['NOMINATIM_IMPORT_STYLE'] = self.import_style
 
-        if self.server_module_path:
-            self.test_env['NOMINATIM_DATABASE_MODULE_PATH'] = self.server_module_path
-
         if self.website_dir is not None:
             self.website_dir.cleanup()
 
         self.website_dir = tempfile.TemporaryDirectory()
 
         if self.website_dir is not None:
             self.website_dir.cleanup()
 
         self.website_dir = tempfile.TemporaryDirectory()
 
-        try:
-            conn = self.connect_database(dbname)
-        except:
-            conn = False
-        refresh.setup_website(Path(self.website_dir.name) / 'website',
-                              self.get_test_config(), conn)
-        if conn:
-            conn.close()
-
 
     def get_test_config(self):
         cfg = Configuration(Path(self.website_dir.name), environ=self.test_env)
 
     def get_test_config(self):
         cfg = Configuration(Path(self.website_dir.name), environ=self.test_env)
-        cfg.set_libdirs(module=self.server_module_path)
         return cfg
 
     def get_libpq_dsn(self):
         return cfg
 
     def get_libpq_dsn(self):
@@ -210,12 +182,8 @@ class NominatimEnvironment:
                     self.run_nominatim('add-data', '--tiger-data', str(testdata / 'tiger'))
                     self.run_nominatim('freeze')
 
                     self.run_nominatim('add-data', '--tiger-data', str(testdata / 'tiger'))
                     self.run_nominatim('freeze')
 
-                    if self.tokenizer == 'legacy':
-                        phrase_file = str(testdata / 'specialphrases_testdb.sql')
-                        run_script(['psql', '-d', self.api_test_db, '-f', phrase_file])
-                    else:
-                        csv_path = str(testdata / 'full_en_phrases_test.csv')
-                        self.run_nominatim('special-phrases', '--import-from-csv', csv_path)
+                    csv_path = str(testdata / 'full_en_phrases_test.csv')
+                    self.run_nominatim('special-phrases', '--import-from-csv', csv_path)
                 except:
                     self.db_drop_database(self.api_test_db)
                     raise
                 except:
                     self.db_drop_database(self.api_test_db)
                     raise
@@ -298,8 +266,7 @@ class NominatimEnvironment:
         if self.website_dir is not None:
             cmdline = list(cmdline) + ['--project-dir', self.website_dir.name]
 
         if self.website_dir is not None:
             cmdline = list(cmdline) + ['--project-dir', self.website_dir.name]
 
-        cli.nominatim(module_dir=self.server_module_path,
-                      osm2pgsql_path=None,
+        cli.nominatim(osm2pgsql_path=None,
                       cli_args=cmdline,
                       environ=self.test_env)
 
                       cli_args=cmdline,
                       environ=self.test_env)