Fix formatting
This commit is contained in:
parent
018407852a
commit
dfb148f8d7
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user