mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
set exception handler by request format, not always HTML
This commit is contained in:
committed by
Marc Tobias Metten
parent
2467e9996e
commit
e4a51e460e
13
test/bdd/api/errors/formats.feature
Normal file
13
test/bdd/api/errors/formats.feature
Normal file
@@ -0,0 +1,13 @@
|
||||
@APIDB
|
||||
Feature: Places by osm_type and osm_id Tests
|
||||
Simple tests for errors in various response formats.
|
||||
|
||||
Scenario Outline: Force error by providing too many ids
|
||||
When sending <format> lookup query for N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27,N28,N29,N30,N31,N32,N33,N34,N35,N36,N37,N38,N39,N40,N41,N42,N43,N44,N45,N46,N47,N48,N49,N50,N51
|
||||
Then a <format> user error is returned
|
||||
|
||||
Examples:
|
||||
| format |
|
||||
| xml |
|
||||
| json |
|
||||
| geojson |
|
||||
@@ -1,6 +1,6 @@
|
||||
@APIDB
|
||||
Feature: Places by osm_type and osm_id Tests
|
||||
Simple tests for internal server errors and response format.
|
||||
Simple tests for response format.
|
||||
|
||||
Scenario Outline: address lookup for existing node, way, relation
|
||||
When sending <format> lookup query for N3284625766,W6065798,,R123924,X99,N0
|
||||
|
||||
@@ -194,7 +194,7 @@ Feature: Simple Tests
|
||||
When sending json search query "Tokyo"
|
||||
| param | value |
|
||||
|json_callback | <data> |
|
||||
Then a HTTP 400 is returned
|
||||
Then a json user error is returned
|
||||
|
||||
Examples:
|
||||
| data |
|
||||
|
||||
@@ -494,6 +494,18 @@ def step_impl(context, fmt):
|
||||
context.execute_steps("Then a HTTP 200 is returned")
|
||||
eq_(context.response.format, fmt)
|
||||
|
||||
@then(u'a (?P<fmt>\w+) user error is returned')
|
||||
def check_page_error(context, fmt):
|
||||
context.execute_steps("Then a HTTP 400 is returned")
|
||||
eq_(context.response.format, fmt)
|
||||
|
||||
if fmt == 'html':
|
||||
assert_is_not_none(re.search(r'<html( |>).+</html>', context.response.page, re.DOTALL))
|
||||
elif fmt == 'xml':
|
||||
assert_is_not_none(re.search(r'<error>.+</error>', context.response.page, re.DOTALL))
|
||||
else:
|
||||
assert_is_not_none(re.search(r'({"error":)', context.response.page, re.DOTALL))
|
||||
|
||||
@then(u'result header contains')
|
||||
def check_header_attr(context):
|
||||
for line in context.table:
|
||||
|
||||
Reference in New Issue
Block a user