mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
improve table comparison
This commit is contained in:
@@ -123,7 +123,7 @@ def db(template_db, pytestconfig):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def db_conn(def_config):
|
||||
def db_conn(db, def_config):
|
||||
with psycopg.connect(def_config.get_libpq_dsn()) as conn:
|
||||
info = psycopg.types.TypeInfo.fetch(conn, "hstore")
|
||||
psycopg.types.hstore.register_hstore(info, conn)
|
||||
@@ -313,22 +313,3 @@ def set_node_grid(datatable, step, origin):
|
||||
raise RuntimeError('Grid origin must be either coordinate or alias.')
|
||||
|
||||
return Grid(datatable, step, origin)
|
||||
|
||||
|
||||
@when('indexing')
|
||||
def do_index(def_config):
|
||||
""" Run Nominatim's indexing step.
|
||||
"""
|
||||
cli.nominatim(['index'], def_config.environ)
|
||||
|
||||
|
||||
@then(step_parse(r'(?P<table>\w+) contains(?P<exact> exactly)?'))
|
||||
def check_place_content(db_conn, datatable, node_grid, table, exact):
|
||||
check_table_content(db_conn, table, datatable, grid=node_grid, exact=bool(exact))
|
||||
|
||||
|
||||
@then(step_parse('(?P<table>placex?) has no entry for '
|
||||
r'(?P<osm_type>[NRW])(?P<osm_id>\d+)(?::(?P<osm_class>\S+))?'),
|
||||
converters={'osm_id': int})
|
||||
def check_place_missing_lines(db_conn, table, osm_type, osm_id, osm_class):
|
||||
check_table_has_lines(db_conn, table, osm_type, osm_id, osm_class)
|
||||
|
||||
@@ -91,4 +91,23 @@ def update_from_osm_file(db_conn, def_config, osm2pgsql_options, opl_writer, doc
|
||||
run_osm2pgsql_updates(db_conn, osm2pgsql_options)
|
||||
|
||||
|
||||
@when('indexing')
|
||||
def do_index(def_config):
|
||||
""" Run Nominatim's indexing step.
|
||||
"""
|
||||
cli.nominatim(['index'], def_config.environ)
|
||||
|
||||
|
||||
@then(step_parse(r'(?P<table>\w+) contains(?P<exact> exactly)?'))
|
||||
def check_place_content(db_conn, datatable, node_grid, table, exact):
|
||||
check_table_content(db_conn, table, datatable, grid=node_grid, exact=bool(exact))
|
||||
|
||||
|
||||
@then(step_parse('(?P<table>placex?) has no entry for '
|
||||
r'(?P<osm_type>[NRW])(?P<osm_id>\d+)(?::(?P<osm_class>\S+))?'),
|
||||
converters={'osm_id': int})
|
||||
def check_place_missing_lines(db_conn, table, osm_type, osm_id, osm_class):
|
||||
check_table_has_lines(db_conn, table, osm_type, osm_id, osm_class)
|
||||
|
||||
|
||||
scenarios('features/osm2pgsql')
|
||||
|
||||
@@ -32,3 +32,15 @@ class Grid:
|
||||
""" Get the coordinates for the given grid node.
|
||||
"""
|
||||
return self.grid.get(nodeid)
|
||||
|
||||
def parse_point(self, value):
|
||||
""" Get the coordinates for either a grid node or a full coordinate.
|
||||
"""
|
||||
value = value.strip()
|
||||
if ' ' in value:
|
||||
return [int(v) for v in value.split(' ', 1)]
|
||||
|
||||
return self.grid.get(value)
|
||||
|
||||
def parse_line(self, value):
|
||||
return [self.parse_point(p) for p in value.split(',')]
|
||||
|
||||
Reference in New Issue
Block a user