diff --git a/tests/test_init.py b/tests/test_init.py index fbf2fc7f..8a1be3e2 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -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