set exception handler by request format, not always HTML

This commit is contained in:
marc tobias
2018-09-16 17:16:42 +02:00
committed by Marc Tobias Metten
parent 2467e9996e
commit e4a51e460e
20 changed files with 247 additions and 80 deletions

View 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 |

View File

@@ -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

View File

@@ -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 |

View File

@@ -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: