Cumulocity-IoT / cumulocity-python-agent

A cumulocity Agent in Python containing the basic functionalities.
Apache License 2.0
2 stars 3 forks source link

Error in reponse code checking due to operator precedence #2

Open solarjoe opened 2 years ago

solarjoe commented 2 years ago

This check does not work as expected as is always True:

if response.status_code == 200 or 201:

https://github.com/SoftwareAG/cumulocity-python-agent/blob/e3f697136584b2d609f88cd6c624f858dd4a0d98/deviceRegistration/newDeviceRegistration.py#L62

Because Python reads it as if (response.status_code == 200) or 201

https://docs.python.org/3/reference/expressions.html#operator-precedence

solarjoe commented 2 years ago

You would write is as if response.status_code in [200, 201]: