+3
-3
@@ -178,14 +178,14 @@ async def get_field(request):
|
|||||||
try:
|
try:
|
||||||
connection = CONNECTIONS[id]
|
connection = CONNECTIONS[id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
response = web.HTTPNotFound()
|
response = web.Response(status=404, reason="Handler ID Not Found")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
content = await connection.get(field)
|
content = await connection.get(field)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return web.Response(status=400, reason="Invalid Resource Path")
|
return web.Response(status=400, reason="Invalid Resource Path")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return web.Response(status=204, reason="Resource Item Not Found")
|
return web.Response(status=404, reason="Resource Item Not Found")
|
||||||
|
|
||||||
if isinstance(content, StreamReader):
|
if isinstance(content, StreamReader):
|
||||||
response = web.StreamResponse(status=200, reason="OK")
|
response = web.StreamResponse(status=200, reason="OK")
|
||||||
@@ -211,7 +211,7 @@ async def set_field(request):
|
|||||||
try:
|
try:
|
||||||
connection = CONNECTIONS[id]
|
connection = CONNECTIONS[id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
response = web.HTTPNotFound()
|
response = web.Response(status=404, reason="Handler ID Not Found")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
await connection.set(field, request.content)
|
await connection.set(field, request.content)
|
||||||
|
|||||||
+6
-6
@@ -4,21 +4,21 @@ Feature: Fail to retrieve resources from nonexistent handler in Kapow! server.
|
|||||||
|
|
||||||
Scenario: Try to get a valid resource path from a nonexistent handler.
|
Scenario: Try to get a valid resource path from a nonexistent handler.
|
||||||
A request to retrieve a resource from a
|
A request to retrieve a resource from a
|
||||||
nonexistent handler will trigger a not found
|
nonexistent handler will trigger
|
||||||
error.
|
a handler ID not found error.
|
||||||
|
|
||||||
Given I have a running Kapow! server
|
Given I have a running Kapow! server
|
||||||
When I get the resource "/request/path" for the handler with id "XXXXXXXXXX"
|
When I get the resource "/request/path" for the handler with id "XXXXXXXXXX"
|
||||||
Then I get 404 as response code
|
Then I get 404 as response code
|
||||||
And I get "Not Found" as response reason phrase
|
And I get "Handler ID Not Found" as response reason phrase
|
||||||
|
|
||||||
Scenario: Try to get an invalid resource from a nonexistent handler.
|
Scenario: Try to get an invalid resource from a nonexistent handler.
|
||||||
A request to retrieve an invalid resource
|
A request to retrieve an invalid resource
|
||||||
from a nonexistent handler will trigger a
|
from a nonexistent handler will trigger a
|
||||||
not found error even if the resource is
|
handler ID not found error
|
||||||
invalid.
|
even if the resource is invalid.
|
||||||
|
|
||||||
Given I have a running Kapow! server
|
Given I have a running Kapow! server
|
||||||
When I get the resource "/invalid/path" for the handler with id "XXXXXXXXXX"
|
When I get the resource "/invalid/path" for the handler with id "XXXXXXXXXX"
|
||||||
Then I get 404 as response code
|
Then I get 404 as response code
|
||||||
And I get "Not Found" as response reason phrase
|
And I get "Handler ID Not Found" as response reason phrase
|
||||||
@@ -12,5 +12,5 @@ Feature: Fail to retrieve nonexistent resource items in Kapow! server.
|
|||||||
| GET | /foo |
|
| GET | /foo |
|
||||||
When I send a request to the testing route "/foo"
|
When I send a request to the testing route "/foo"
|
||||||
And I get the resource "/request/params/meloinvento"
|
And I get the resource "/request/params/meloinvento"
|
||||||
Then I get 204 as response code
|
Then I get 404 as response code
|
||||||
And I get "Resource Item Not Found" as response reason phrase
|
And I get "Resource Item Not Found" as response reason phrase
|
||||||
|
|||||||
Reference in New Issue
Block a user