forked from hans/Nominatim
add basic tests for namedetails and extratags parameters
This commit is contained in:
@@ -36,3 +36,28 @@ Feature: Reverse geocoding
|
|||||||
| 0 | Kings Estate Drive | 84128 | us
|
| 0 | Kings Estate Drive | 84128 | us
|
||||||
And result 0 has attributes osm_id,osm_type
|
And result 0 has attributes osm_id,osm_type
|
||||||
|
|
||||||
|
Scenario Outline: Reverse Geocoding with extratags
|
||||||
|
Given the request parameters
|
||||||
|
| extratags
|
||||||
|
| 1
|
||||||
|
When looking up <format> coordinates 48.86093,2.2978
|
||||||
|
Then result 0 has attributes extratags
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| format
|
||||||
|
| xml
|
||||||
|
| json
|
||||||
|
| jsonv2
|
||||||
|
|
||||||
|
Scenario Outline: Reverse Geocoding with namedetails
|
||||||
|
Given the request parameters
|
||||||
|
| namedetails
|
||||||
|
| 1
|
||||||
|
When looking up <format> coordinates 48.86093,2.2978
|
||||||
|
Then result 0 has attributes namedetails
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| format
|
||||||
|
| xml
|
||||||
|
| json
|
||||||
|
| jsonv2
|
||||||
|
|||||||
@@ -202,3 +202,31 @@ Feature: Search queries
|
|||||||
| 0.5
|
| 0.5
|
||||||
| 999
|
| 999
|
||||||
| nan
|
| nan
|
||||||
|
|
||||||
|
Scenario Outline: Search with extratags
|
||||||
|
Given the request parameters
|
||||||
|
| extratags
|
||||||
|
| 1
|
||||||
|
When sending <format> search query "Hauptstr"
|
||||||
|
Then result 0 has attributes extratags
|
||||||
|
And result 1 has attributes extratags
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| format
|
||||||
|
| xml
|
||||||
|
| json
|
||||||
|
| jsonv2
|
||||||
|
|
||||||
|
Scenario Outline: Search with namedetails
|
||||||
|
Given the request parameters
|
||||||
|
| namedetails
|
||||||
|
| 1
|
||||||
|
When sending <format> search query "Hauptstr"
|
||||||
|
Then result 0 has attributes namedetails
|
||||||
|
And result 1 has attributes namedetails
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| format
|
||||||
|
| xml
|
||||||
|
| json
|
||||||
|
| jsonv2
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ Feature: Simple Tests
|
|||||||
| limit | 1000
|
| limit | 1000
|
||||||
| dedupe | 1
|
| dedupe | 1
|
||||||
| dedupe | 0
|
| dedupe | 0
|
||||||
|
| extratags | 1
|
||||||
|
| extratags | 0
|
||||||
|
| namedetails | 1
|
||||||
|
| namedetails | 0
|
||||||
|
|
||||||
Scenario: Search with invalid output format
|
Scenario: Search with invalid output format
|
||||||
Given the request parameters
|
Given the request parameters
|
||||||
|
|||||||
@@ -34,10 +34,28 @@ def _parse_xml():
|
|||||||
newresult = OrderedDict(node.attributes.items())
|
newresult = OrderedDict(node.attributes.items())
|
||||||
assert_not_in('address', newresult)
|
assert_not_in('address', newresult)
|
||||||
assert_not_in('geokml', newresult)
|
assert_not_in('geokml', newresult)
|
||||||
|
assert_not_in('extratags', newresult)
|
||||||
|
assert_not_in('namedetails', newresult)
|
||||||
address = OrderedDict()
|
address = OrderedDict()
|
||||||
for sub in node.childNodes:
|
for sub in node.childNodes:
|
||||||
if sub.nodeName == 'geokml':
|
if sub.nodeName == 'geokml':
|
||||||
newresult['geokml'] = sub.childNodes[0].toxml()
|
newresult['geokml'] = sub.childNodes[0].toxml()
|
||||||
|
elif sub.nodeName == 'extratags':
|
||||||
|
newresult['extratags'] = {}
|
||||||
|
for tag in sub.childNodes:
|
||||||
|
assert_equals(tag.nodeName, 'tag')
|
||||||
|
attrs = dict(tag.attributes.items())
|
||||||
|
assert_in('key', attrs)
|
||||||
|
assert_in('value', attrs)
|
||||||
|
newresult['extratags'][attrs['key']] = attrs['value']
|
||||||
|
elif sub.nodeName == 'namedetails':
|
||||||
|
newresult['namedetails'] = {}
|
||||||
|
for tag in sub.childNodes:
|
||||||
|
assert_equals(tag.nodeName, 'name')
|
||||||
|
attrs = dict(tag.attributes.items())
|
||||||
|
assert_in('desc', attrs)
|
||||||
|
newresult['namedetails'][attrs['desc']] = tag.firstChild.nodeValue.strip()
|
||||||
|
|
||||||
elif sub.nodeName == '#text':
|
elif sub.nodeName == '#text':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@@ -65,6 +83,21 @@ def _parse_xml():
|
|||||||
for sub in node.childNodes:
|
for sub in node.childNodes:
|
||||||
address[sub.nodeName] = sub.firstChild.nodeValue.strip()
|
address[sub.nodeName] = sub.firstChild.nodeValue.strip()
|
||||||
world.results[0]['address'] = address
|
world.results[0]['address'] = address
|
||||||
|
elif node.nodeName == 'extratags':
|
||||||
|
world.results[0]['extratags'] = {}
|
||||||
|
for tag in node.childNodes:
|
||||||
|
assert_equals(tag.nodeName, 'tag')
|
||||||
|
attrs = dict(tag.attributes.items())
|
||||||
|
assert_in('key', attrs)
|
||||||
|
assert_in('value', attrs)
|
||||||
|
world.results[0]['extratags'][attrs['key']] = attrs['value']
|
||||||
|
elif node.nodeName == 'namedetails':
|
||||||
|
world.results[0]['namedetails'] = {}
|
||||||
|
for tag in node.childNodes:
|
||||||
|
assert_equals(tag.nodeName, 'name')
|
||||||
|
attrs = dict(tag.attributes.items())
|
||||||
|
assert_in('desc', attrs)
|
||||||
|
world.results[0]['namedetails'][attrs['desc']] = tag.firstChild.nodeValue.strip()
|
||||||
elif node.nodeName == "#text":
|
elif node.nodeName == "#text":
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@@ -92,6 +125,8 @@ def api_result_is_valid(step, fmt):
|
|||||||
_parse_xml()
|
_parse_xml()
|
||||||
elif world.response_format == 'json':
|
elif world.response_format == 'json':
|
||||||
world.results = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(world.page)
|
world.results = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(world.page)
|
||||||
|
if world.request_type == 'reverse':
|
||||||
|
world.results = (world.results,)
|
||||||
else:
|
else:
|
||||||
assert False, "Unknown page format: %s" % (world.response_format)
|
assert False, "Unknown page format: %s" % (world.response_format)
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import logging
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def api_call(requesttype):
|
def api_call(requesttype):
|
||||||
|
world.request_type = requesttype
|
||||||
world.json_callback = None
|
world.json_callback = None
|
||||||
data = urllib.urlencode(world.params)
|
data = urllib.urlencode(world.params)
|
||||||
url = "%s/%s?%s" % (world.config.base_url, requesttype, data)
|
url = "%s/%s?%s" % (world.config.base_url, requesttype, data)
|
||||||
|
|||||||
Reference in New Issue
Block a user