forked from hans/Nominatim
remove special casing for legacy tokenizer from BDD tests
This commit is contained in:
@@ -34,7 +34,6 @@ class NominatimEnvironment:
|
||||
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']
|
||||
|
||||
@@ -48,9 +47,6 @@ class NominatimEnvironment:
|
||||
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.")
|
||||
|
||||
def connect_database(self, dbname):
|
||||
""" Return a connection to the database with the given name.
|
||||
Uses configured host, user and port.
|
||||
@@ -100,9 +96,6 @@ class NominatimEnvironment:
|
||||
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()
|
||||
|
||||
@@ -111,7 +104,6 @@ class NominatimEnvironment:
|
||||
|
||||
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):
|
||||
@@ -190,12 +182,8 @@ class NominatimEnvironment:
|
||||
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
|
||||
@@ -278,7 +266,7 @@ class NominatimEnvironment:
|
||||
if self.website_dir is not None:
|
||||
cmdline = list(cmdline) + ['--project-dir', self.website_dir.name]
|
||||
|
||||
cli.nominatim(module_dir=self.server_module_path,
|
||||
cli.nominatim(module_dir=None,
|
||||
osm2pgsql_path=None,
|
||||
cli_args=cmdline,
|
||||
environ=self.test_env)
|
||||
|
||||
@@ -28,9 +28,8 @@ def check_database_integrity(context):
|
||||
assert cur.fetchone()[0] == 0, "Duplicates found in place_addressline"
|
||||
|
||||
# word table must not have empty word_tokens
|
||||
if context.nominatim.tokenizer != 'legacy':
|
||||
cur.execute("SELECT count(*) FROM word WHERE word_token = ''")
|
||||
assert cur.fetchone()[0] == 0, "Empty word tokens found in word table"
|
||||
cur.execute("SELECT count(*) FROM word WHERE word_token = ''")
|
||||
assert cur.fetchone()[0] == 0, "Empty word tokens found in word table"
|
||||
|
||||
|
||||
|
||||
@@ -324,13 +323,8 @@ def check_word_table_for_postcodes(context, exclude, postcodes):
|
||||
plist.sort()
|
||||
|
||||
with context.db.cursor() as cur:
|
||||
if nctx.tokenizer != 'legacy':
|
||||
cur.execute("SELECT word FROM word WHERE type = 'P' and word = any(%s)",
|
||||
(plist,))
|
||||
else:
|
||||
cur.execute("""SELECT word FROM word WHERE word = any(%s)
|
||||
and class = 'place' and type = 'postcode'""",
|
||||
(plist,))
|
||||
cur.execute("SELECT word FROM word WHERE type = 'P' and word = any(%s)",
|
||||
(plist,))
|
||||
|
||||
found = [row['word'] for row in cur]
|
||||
assert len(found) == len(set(found)), f"Duplicate rows for postcodes: {found}"
|
||||
|
||||
Reference in New Issue
Block a user