New error handling in poc and features

This commit is contained in:
Héctor Hurtado
2019-11-14 15:05:19 +01:00
parent 9ebc989bc7
commit ee9bb8df9c
11 changed files with 95 additions and 20 deletions
@@ -28,4 +28,10 @@ Feature: Kapow! server reject append requests with malformed JSON bodies.
Hi! I am an invalid JSON document.
"""
Then I get 400 as response code
And I get "Malformed JSON" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Malformed JSON"
}
"""
@@ -31,7 +31,13 @@ Feature: Kapow! server rejects requests with semantic errors.
}
"""
Then I get 422 as response code
And I get "Invalid Route" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Invalid Route"
}
"""
Scenario: Error because bad route format.
If a request contains an invalid expression in the
@@ -48,4 +54,10 @@ Feature: Kapow! server rejects requests with semantic errors.
}
"""
Then I get 422 as response code
And I get "Invalid Route" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Invalid Route"
}
"""
@@ -24,4 +24,10 @@ Feature: Fail to delete a route in Kapow! server.
Given I have a just started Kapow! server
When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get 404 as response code
And I get "Not Found" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Route Not Found"
}
"""
@@ -24,4 +24,10 @@ Feature: Fail to retrieve route details in Kapow! server.
Given I have a just started Kapow! server
When I get the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get 404 as response code
And I get "Not Found" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Route Not Found"
}
"""
@@ -37,4 +37,10 @@ Feature: Kapow! server rejects insertion requests with malformed JSON bodies.
}
"""
Then I get 400 as response code
And I get "Malformed JSON" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Malformed JSON"
}
"""
@@ -67,4 +67,10 @@ Feature: Kapow! server rejects insertion requests with semantic errors.
}
"""
Then I get 422 as response code
And I get "Invalid Route" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Invalid Route"
}
"""
@@ -25,4 +25,10 @@ Feature: Fail to retrieve resources from nonexistent handler in Kapow! server.
Given I have a running Kapow! server
When I get the resource "/request/path" for the handler with id "XXXXXXXXXX"
Then I get 404 as response code
And I get "Handler ID Not Found" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Handler ID Not Found"
}
"""
@@ -27,4 +27,10 @@ Feature: Fail to retrieve an invalid resource for a handler in Kapow! server.
When I send a request to the testing route "/foo"
And I get the resource "/invented/path"
Then I get 400 as response code
And I get "Invalid Resource Path" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Invalid Resource Path"
}
"""
@@ -28,4 +28,10 @@ Feature: Fail to retrieve nonexistent resource items in Kapow! server.
When I send a request to the testing route "/foo"
And I get the resource "/request/params/meloinvento"
Then I get 404 as response code
And I get "Resource Item Not Found" as response reason phrase
And the response header "Content-Type" contains "application/json"
And I get the following response body:
"""
{
"reason": "Resource Item Not Found"
}
"""
+10
View File
@@ -185,6 +185,16 @@ def step_impl(context, code):
assert context.testing_response.status_code == int(code), f"Got {context.testing_response.status_code} instead"
@then('the response header {header_name} contains {value}')
def step_impl(context, header_name, value):
assert context.response.headers.get(header_name) == value, f"Got {context.response.headers.get(header_name)} instead"
@then('the testing response header {header_name} contains {value}')
def step_impl(context, header_name, value):
assert context.testing_response.headers.get(header_name) == value, f"Got {context.testing_response.headers.get(header_name)} instead"
@then('I get "{reason}" as response reason phrase')
def step_impl(context, reason):
assert context.response.reason == reason, f"Got {context.response.reason} instead"