mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-15 10:57:58 +00:00
reorganise fixtures for placex table
Now follows the same pattern as fixtures for other tables and uses the production SQL for table creation.
This commit is contained in:
@@ -22,7 +22,6 @@ from nominatim_db.db.sql_preprocessor import SQLPreprocessor
|
||||
import nominatim_db.tokenizer.factory
|
||||
|
||||
import dummy_tokenizer
|
||||
import mocks
|
||||
from cursor import CursorForTesting
|
||||
|
||||
|
||||
@@ -243,10 +242,37 @@ def place_postcode_row(place_postcode_table, temp_db_cursor):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def placex_table(temp_db_with_extensions, temp_db_conn):
|
||||
""" Create an empty version of the place table.
|
||||
def placex_table(temp_db_with_extensions, temp_db_conn, load_sql, place_table):
|
||||
""" Create an empty version of the placex table.
|
||||
"""
|
||||
return mocks.MockPlacexTable(temp_db_conn)
|
||||
load_sql('tables/placex.sql')
|
||||
temp_db_conn.execute("CREATE SEQUENCE IF NOT EXISTS seq_place START 1")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def placex_row(placex_table, temp_db_cursor):
|
||||
""" A factory for rows in the placex table. The table is created as a
|
||||
prerequisite to the fixture.
|
||||
"""
|
||||
idseq = itertools.count(1001)
|
||||
|
||||
def _add(osm_type='N', osm_id=None, cls='amenity', typ='cafe', names=None,
|
||||
admin_level=None, address=None, extratags=None, geom='POINT(10 4)',
|
||||
country=None, housenumber=None, rank_search=30, rank_address=30,
|
||||
centroid='POINT(10 4)', indexed_status=0, indexed_date=None):
|
||||
args = {'place_id': pysql.SQL("nextval('seq_place')"),
|
||||
'osm_type': osm_type, 'osm_id': osm_id or next(idseq),
|
||||
'class': cls, 'type': typ, 'name': names, 'admin_level': admin_level,
|
||||
'address': address, 'housenumber': housenumber,
|
||||
'rank_search': rank_search, 'rank_address': rank_address,
|
||||
'extratags': extratags,
|
||||
'centroid': _with_srid(centroid), 'geometry': _with_srid(geom),
|
||||
'country_code': country,
|
||||
'indexed_status': indexed_status, 'indexed_date': indexed_date,
|
||||
'partition': pysql.Literal(0), 'geometry_sector': pysql.Literal(1)}
|
||||
return temp_db_cursor.insert_row('placex', **args)
|
||||
|
||||
return _add
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user