]> git.openstreetmap.org Git - nominatim.git/blobdiff - tests/steps/api_setup.py
add mention of required Tiger files for test database
[nominatim.git] / tests / steps / api_setup.py
index dc39a3bc9069d4e071bc8991ef8896cfbc48475b..c9a4bac476df5818df06cea9b4312a0fdc2a78c8 100644 (file)
@@ -10,6 +10,7 @@ import logging
 logger = logging.getLogger(__name__)
 
 def api_call(requesttype):
+    world.request_type = requesttype
     world.json_callback = None
     data = urllib.urlencode(world.params)
     url = "%s/%s?%s" % (world.config.base_url, requesttype, data)
@@ -36,7 +37,7 @@ def api_call(requesttype):
         world.response_format = fmt
     elif fmt in ('json', 'jsonv2'):
         if 'json_callback' in world.params:
-            world.json_callback = world.params['json_callback']
+            world.json_callback = world.params['json_callback'].encode('utf8')
             assert world.page.startswith(world.json_callback + '(')
             assert world.page.endswith(')')
             world.page = world.page[(len(world.json_callback)+1):-1]
@@ -104,7 +105,7 @@ def api_setup_reverse(step, fmt, lat, lon):
     api_call('reverse')
 
 @step(u'looking up place ([NRW]?\d+)')
-def api_setup_details(step, obj):
+def api_setup_details_reverse(step, obj):
     if obj[0] in ('N', 'R', 'W'):
         # an osm id
         world.params['osm_type']  = obj[0]
@@ -122,3 +123,14 @@ def api_setup_details(step, obj):
     else:
         world.params['place_id']  = obj
     api_call('details')
+
+@step(u'looking up (\w+) places ((?:[a-z]\d+,*)+)')
+def api_setup_lookup(step, fmt, ids):
+    world.params['osm_ids'] = ids
+    if fmt and fmt.strip():
+        world.params['format'] = fmt.strip()
+    api_call('lookup')
+
+@step(u'sending an API call (\w+)')
+def api_general_call(step, call):
+    api_call(call)