Skip to content

Commit

Permalink
Fixing the missing reason for API faulty response on disabled relay u…
Browse files Browse the repository at this point in the history
…pdate.
  • Loading branch information
RobinTail committed Oct 22, 2023
1 parent a72b2c3 commit 749c845
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions octoprint_octorelay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def on_api_command(self, command, data):
return flask.jsonify({ "status": "ok", "result": state }) # todo remove branch when dropping v1
return flask.jsonify({ "status": state })
except HandlingException as exception: # todo: deprecate the behavior for 400, only abort in next version
if version == 1 and exception.status == 400:
return flask.jsonify({ "status": "error" }) # todo remove this branch when dropping v1
if version == 1 and exception.status == 400: # todo remove this branch when dropping v1
return flask.jsonify({ "status": "error", "reason": f"Can not toggle the relay {subject}" })
return flask.abort(exception.status)
# API command to cancel the postponed toggling task
if command == CANCEL_TASK_COMMAND:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ def test_on_api_command__update_exceptions(self, jsonify_mock, abort_mock):
"payload": { "pin": "r4" },
"status": 400,
"expectedMethod": jsonify_mock,
"expectedArgument": { "status": "error"}
"expectedArgument": { "status": "error", "reason": "Can not toggle the relay r4" }
},
{
"payload": { "v": 2, "subject": "r4" },
Expand Down

0 comments on commit 749c845

Please sign in to comment.