]> git.openstreetmap.org Git - nominatim.git/blobdiff - tests/steps/terrain.py
make path to wikipedia files configurable
[nominatim.git] / tests / steps / terrain.py
index 312d76cf586cafaac8d09c2f806e2c3027886345..80beebd5a49c8bb67b97268bd19ab7c4c7b6585f 100644 (file)
@@ -123,16 +123,19 @@ def match_geometry(coord, matchstring):
     logger.debug("Distances expected: %f, got: %f" % (expdist, dist))
     assert dist <= expdist, "Geometry too far away, expected: %f, got: %f" % (expdist, dist)
 
+@world.absorb
+def print_statement(element):
+    print '\n\n\n'+str(element)+'\n\n\n'
 
 
 @world.absorb
 def db_dump_table(table):
     cur = world.conn.cursor()
     cur.execute('SELECT * FROM %s' % table)
-    print '<<<<<<< BEGIN OF TABLE DUMP %s' % table
+    print '\n\n\n<<<<<<< BEGIN OF TABLE DUMP %s' % table
     for res in cur:
             print res
-    print '<<<<<<< END OF TABLE DUMP %s' % table
+    print '<<<<<<< END OF TABLE DUMP %s\n\n\n' % table
 
 @world.absorb
 def db_drop_database(name):
@@ -172,8 +175,10 @@ def db_template_setup():
     conn = psycopg2.connect(database=world.config.template_db)
     psycopg2.extras.register_hstore(conn, globally=False, unicode=True)
     cur = conn.cursor()
-    for table in ('gb_postcode', 'us_postcode', 'us_state', 'us_statecounty'):
-        cur.execute('TRUNCATE TABLE %s' % (table,))
+    for table in ('gb_postcode', 'us_postcode'):
+        cur.execute("select * from pg_tables where tablename = '%s'" % (table, ))
+        if cur.rowcount > 0:
+            cur.execute('TRUNCATE TABLE %s' % (table,))
     conn.commit()
     conn.close()
     # execute osm2pgsql on an empty file to get the right tables