forked from hans/Nominatim
add function for inserting data to testing cursor
This commit is contained in:
@@ -178,12 +178,14 @@ def place_row(place_table, temp_db_cursor):
|
||||
prerequisite to the fixture.
|
||||
"""
|
||||
idseq = itertools.count(1001)
|
||||
|
||||
def _insert(osm_type='N', osm_id=None, cls='amenity', typ='cafe', names=None,
|
||||
admin_level=None, address=None, extratags=None, geom=None):
|
||||
temp_db_cursor.execute("INSERT INTO place VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
(osm_id or next(idseq), osm_type, cls, typ, names,
|
||||
admin_level, address, extratags,
|
||||
geom or 'SRID=4326;POINT(0 0)'))
|
||||
admin_level=None, address=None, extratags=None, geom='POINT(0 0)'):
|
||||
args = {'osm_type': osm_type, 'osm_id': osm_id or next(idseq),
|
||||
'class': cls, 'type': typ, 'name': names, 'admin_level': admin_level,
|
||||
'address': address, 'extratags': extratags,
|
||||
'geometry': _with_srid(geom)}
|
||||
temp_db_cursor.insert_row('place', **args)
|
||||
|
||||
return _insert
|
||||
|
||||
@@ -203,17 +205,18 @@ def place_postcode_table(temp_db_with_extensions, table_factory):
|
||||
|
||||
@pytest.fixture
|
||||
def place_postcode_row(place_postcode_table, temp_db_cursor):
|
||||
""" A factory for rows in the place table. The table is created as a
|
||||
""" A factory for rows in the place_postcode table. The table is created as a
|
||||
prerequisite to the fixture.
|
||||
"""
|
||||
idseq = itertools.count(5001)
|
||||
|
||||
def _insert(osm_type='N', osm_id=None, postcode=None, country=None,
|
||||
centroid=None, geom=None):
|
||||
temp_db_cursor.execute("INSERT INTO place_postcode VALUES (%s, %s, %s, %s, %s, %s)",
|
||||
(osm_type, osm_id or next(idseq),
|
||||
postcode, country,
|
||||
_with_srid(centroid, 'POINT(12.0 4.0)'),
|
||||
_with_srid(geom)))
|
||||
centroid='POINT(12.0 4.0)', geom=None):
|
||||
temp_db_cursor.insert_row('place_postcode',
|
||||
osm_type=osm_type, osm_id=osm_id or next(idseq),
|
||||
postcode=postcode, country_code=country,
|
||||
centroid=_with_srid(centroid),
|
||||
geometry=_with_srid(geom))
|
||||
|
||||
return _insert
|
||||
|
||||
|
||||
Reference in New Issue
Block a user