diff --git a/freqtrade/rpc/webhook.py b/freqtrade/rpc/webhook.py index 2a848787d..58b75769e 100644 --- a/freqtrade/rpc/webhook.py +++ b/freqtrade/rpc/webhook.py @@ -79,7 +79,8 @@ class Webhook(RPCHandler): attempts = 0 while not success and attempts <= self._retries: if attempts: - if self._retry_delay: time.sleep(self._retry_delay) + if self._retry_delay: + time.sleep(self._retry_delay) logger.info("Retrying webhook...") attempts += 1 @@ -90,10 +91,11 @@ class Webhook(RPCHandler): elif self._format == 'json': response = post(self._url, json=payload) elif self._format == 'raw': - response = post(self._url, data=payload['data'], headers={'Content-Type': 'text/plain'}) + response = post(self._url, data=payload['data'], + headers={'Content-Type': 'text/plain'}) else: raise NotImplementedError('Unknown format: {}'.format(self._format)) - + # Throw a RequestException if the post was not successful response.raise_for_status() success = True diff --git a/tests/rpc/test_rpc_webhook.py b/tests/rpc/test_rpc_webhook.py index 735d2ada2..17d1baca9 100644 --- a/tests/rpc/test_rpc_webhook.py +++ b/tests/rpc/test_rpc_webhook.py @@ -293,6 +293,7 @@ def test__send_msg_with_json_format(default_conf, mocker, caplog): assert post.call_args[1] == {'json': msg} + def test__send_msg_with_raw_format(default_conf, mocker, caplog): default_conf["webhook"] = get_webhook_dict() default_conf["webhook"]["format"] = "raw"