mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
Fixes bug when dealing with empty JSON requests or empty appointment field
When posting a request via requests.post the json field was dumped to json, but it shouldn't have been since requests deals with this internally. That meant that the requests made by the code didn't match proper JSON. In line with this, the API was only parsing this type POST requests correctly, making add_appointment to fail if a proper formatted JSON was passed. On top of that, empty appointments were not checked in the Inspector before trying to get data from them, making it crash if a JSON was posted to add_appointment not containing the `appointment` field. Unit tests for this should be added.
This commit is contained in:
@@ -72,7 +72,7 @@ def new_appt_data():
|
||||
|
||||
|
||||
def add_appointment(new_appt_data):
|
||||
r = requests.post(url=add_appointment_endpoint, json=json.dumps(new_appt_data), timeout=5)
|
||||
r = requests.post(url=add_appointment_endpoint, json=new_appt_data, timeout=5)
|
||||
|
||||
if r.status_code == 200:
|
||||
appointments.append(new_appt_data["appointment"])
|
||||
|
||||
Reference in New Issue
Block a user