Skip to content

Commit

Permalink
Testing the faulty case.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Oct 18, 2023
1 parent ade7c08 commit 2c29bfa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,13 @@ def test_on_api_command(self, jsonify_mock):
case["expectedMethod"].assert_called_with(*case["expectedArguments"])
case["expectedOutcome"].assert_called_with(case["expectedPayload"])

@patch("flask.abort")
def test_on_api_command__exceptions(self, abort_mock):
# Should respond with a faulty HTTP code when handler raises
self.plugin_instance.handle_update_command = Mock(side_effect=Exception("Bad request"))
self.plugin_instance.on_api_command("update", {})
abort_mock.assert_called_with(400)

@patch("flask.abort")
def test_on_api_command__unknown(self, abort_mock):
# Should respond with status code 400 (bad request) to unknown commands
Expand Down

0 comments on commit 2c29bfa

Please sign in to comment.