Files
zulip/zerver/webhooks/alertmanager/tests.py
Anders Kaseorg c734bbd95d python: Modernize legacy Python 2 syntax with pyupgrade.
Generated by `pyupgrade --py3-plus --keep-percent-format` on all our
Python code except `zthumbor` and `zulip-ec2-configure-interfaces`,
followed by manual indentation fixes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-09 16:43:22 -07:00

36 lines
1.4 KiB
Python

from zerver.lib.test_classes import WebhookTestCase
class AlertmanagerHookTests(WebhookTestCase):
STREAM_NAME = 'alertmanager'
URL_TEMPLATE = "/api/v1/external/alertmanager?&api_key={api_key}&stream={stream}&name=topic&desc=description"
FIXTURE_DIR_NAME = 'alertmanager'
def test_error_issue_message(self) -> None:
expected_topic = "andromeda"
expected_message = """
:alert: **FIRING**
* CPU core temperature is 34.75C ([graph](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
* CPU core temperature is 17.625C ([graph](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
""".strip()
self.send_and_test_stream_message(
'alert',
expected_topic,
expected_message,
"application/json"
)
def test_single_error_issue_message(self) -> None:
expected_topic = "andromeda"
expected_message = """
:squared_ok: **Resolved** CPU core temperature is 34.75C ([graph](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
""".strip()
self.send_and_test_stream_message(
'single_alert',
expected_topic,
expected_message,
"application/json"
)