forked from hans/Nominatim
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:
@@ -8,6 +8,7 @@
|
||||
Tests for maintenance and analysis functions.
|
||||
"""
|
||||
import pytest
|
||||
import datetime as dt
|
||||
|
||||
from nominatim_db.errors import UsageError
|
||||
from nominatim_db.tools import admin
|
||||
@@ -61,15 +62,14 @@ def test_analyse_indexing_unknown_osmid(project_env):
|
||||
admin.analyse_indexing(project_env, osm_id='W12345674')
|
||||
|
||||
|
||||
def test_analyse_indexing_with_place_id(project_env, temp_db_cursor):
|
||||
temp_db_cursor.execute("INSERT INTO placex (place_id) VALUES(12345)")
|
||||
def test_analyse_indexing_with_place_id(project_env, placex_row):
|
||||
place_id = placex_row()
|
||||
|
||||
admin.analyse_indexing(project_env, place_id=12345)
|
||||
admin.analyse_indexing(project_env, place_id=place_id)
|
||||
|
||||
|
||||
def test_analyse_indexing_with_osm_id(project_env, temp_db_cursor):
|
||||
temp_db_cursor.execute("""INSERT INTO placex (place_id, osm_type, osm_id)
|
||||
VALUES(9988, 'N', 10000)""")
|
||||
def test_analyse_indexing_with_osm_id(project_env, placex_row):
|
||||
placex_row(osm_type='N', osm_id=10000)
|
||||
|
||||
admin.analyse_indexing(project_env, osm_id='N10000')
|
||||
|
||||
@@ -77,7 +77,7 @@ def test_analyse_indexing_with_osm_id(project_env, temp_db_cursor):
|
||||
class TestAdminCleanDeleted:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_polygon_delete(self, project_env, table_factory, country_table, place_table,
|
||||
def setup_polygon_delete(self, project_env, table_factory, place_table, placex_row,
|
||||
osmline_table, temp_db_cursor, temp_db_conn, def_config, src_dir):
|
||||
""" Set up place_force_delete function and related tables
|
||||
"""
|
||||
@@ -91,12 +91,15 @@ class TestAdminCleanDeleted:
|
||||
((100, 'N', 'boundary', 'administrative'),
|
||||
(145, 'N', 'boundary', 'administrative'),
|
||||
(175, 'R', 'landcover', 'grass')))
|
||||
temp_db_cursor.execute("""
|
||||
INSERT INTO placex (place_id, osm_id, osm_type, class, type,
|
||||
indexed_date, indexed_status)
|
||||
VALUES(1, 100, 'N', 'boundary', 'administrative', current_date - INTERVAL '1 month', 1),
|
||||
(2, 145, 'N', 'boundary', 'administrative', current_date - INTERVAL '3 month', 1),
|
||||
(3, 175, 'R', 'landcover', 'grass', current_date - INTERVAL '3 months', 1)""")
|
||||
|
||||
now = dt.datetime.now()
|
||||
placex_row(osm_type='N', osm_id=100, cls='boundary', typ='administrative',
|
||||
indexed_status=1, indexed_date=now - dt.timedelta(days=30))
|
||||
placex_row(osm_type='N', osm_id=145, cls='boundary', typ='administrative',
|
||||
indexed_status=1, indexed_date=now - dt.timedelta(days=90))
|
||||
placex_row(osm_type='R', osm_id=175, cls='landcover', typ='grass',
|
||||
indexed_status=1, indexed_date=now - dt.timedelta(days=90))
|
||||
|
||||
# set up tables and triggers for utils function
|
||||
table_factory('place_to_be_deleted',
|
||||
"""osm_id BIGINT,
|
||||
|
||||
Reference in New Issue
Block a user