refactor: Parse JSON from bots in one place.

We move the JSON parsing step into the
higher level function: process_success_response().

In the unlikely event that we'll start integrating
with a solution that doesn't use JSON, we can deal
with that, and for now doing the parsing in one
place will help us make error reporting more
consistent.

In a subsequent commit we'll introduce better
error handling for malformed JSON.
This commit is contained in:
Steve Howell
2018-10-10 11:16:42 +00:00
committed by Tim Abbott
parent 395d74c08a
commit df4b665658
3 changed files with 12 additions and 18 deletions

View File

@@ -27,7 +27,7 @@ def timeout_error(http_method: Any, final_url: Any, data: Any, **request_kwargs:
raise requests.exceptions.Timeout("Time is up!")
class MockServiceHandler(OutgoingWebhookServiceInterface):
def process_success(self, response: Response, event: Dict[str, Any]) -> Optional[Dict[str, Any]]:
def process_success(self, response_json: Dict[str, Any], event: Dict[str, Any]) -> Optional[Dict[str, Any]]:
# Our tests don't really look at the content yet.
# They just ensure we use the "success" codepath.
success_data = dict(