2 Tests for maintenance and analysis functions.
 
   6 from nominatim.db.connection import connect
 
   7 from nominatim.errors import UsageError
 
   8 from nominatim.tools import admin
 
  11 def db(temp_db, placex_table):
 
  12     with connect('dbname=' + temp_db) as conn:
 
  15 def test_analyse_indexing_no_objects(db):
 
  16     with pytest.raises(UsageError):
 
  17         admin.analyse_indexing(db)
 
  20 @pytest.mark.parametrize("oid", ['1234', 'N123a', 'X123'])
 
  21 def test_analyse_indexing_bad_osmid(db, oid):
 
  22     with pytest.raises(UsageError):
 
  23         admin.analyse_indexing(db, osm_id=oid)
 
  26 def test_analyse_indexing_unknown_osmid(db):
 
  27     with pytest.raises(UsageError):
 
  28         admin.analyse_indexing(db, osm_id='W12345674')
 
  31 def test_analyse_indexing_with_place_id(db, temp_db_cursor):
 
  32     temp_db_cursor.execute("INSERT INTO placex (place_id) VALUES(12345)")
 
  34     admin.analyse_indexing(db, place_id=12345)
 
  37 def test_analyse_indexing_with_osm_id(db, temp_db_cursor):
 
  38     temp_db_cursor.execute("""INSERT INTO placex (place_id, osm_type, osm_id)
 
  39                               VALUES(9988, 'N', 10000)""")
 
  41     admin.analyse_indexing(db, osm_id='N10000')