osmlab / maproulette-python-client

MapRoulette Client Library for Python
https://maproulette-python-client.readthedocs.io
Apache License 2.0
11 stars 12 forks source link

Changed response handling in case of JSON deserializing error #80

Closed mattmanley closed 3 years ago

mattmanley commented 3 years ago

Description:

This PR refactors the response dictionary that is created by the various get, post, put, and delete methods in maproulette_server.py. Originally, the response dictionary would contain both the status code and the response.json() object if it could successfully decode the JSON. If decoding failed, the response dictionary would contain only the status code. I've now included the response.text object in the response dictionary in the cases where the JSON cannot be decoded.

This has an important impact on the extract_task_summaries method. This method is supposed to return a CSV payload of task summaries. However, this payload is returned in the response.text object. This change allows the user to access this payload just as they normally would for other methods by using the resulting response['data'] object that is created from the get request.

I also made a small nit edit to some docstrings that I didn't catch previously.

Potential Impact:

Makes the extract_task_summaries method usable. I don't think that this has any adverse impact on functionality since the response.text object will only be delivered in the cases of JSON decoding failing. In those cases, we only delivered the status code, so in my opinion this is an enhancement that shouldn't break anything.

Unit Test Approach:

N/A

Test Results:

Tox tests are passing.