from datetime import datetime from mock import MagicMock from zmon_worker_monitor.zmon_worker.encoder import JsonDataEncoder from zmon_worker_monitor.zmon_worker.notifications.opsgenie import NotifyOpsgenie, NotificationError, get_user_agent URL_CREATE = 'https://api.opsgenie.com/v2/alerts' URL_CLOSE = 'https://api.opsgenie.com/v2/alerts/{}/close' API_KEY = '123' MESSAGE = 'ZMON ALERT' HEADERS = { 'User-Agent': get_user_agent(), 'Content-type': 'application/json', 'Authorization': 'GenieKey {}'.format(API_KEY), } @pytest.mark.parametrize('is_alert,priority,override_description,set_custom_fileds', ((True, None, None, None), (True, 'P4', None, None), (False, None, None, None), (True, None, "override description", None), (True, None, None, {'custom_field': 'values'})) ) def test_opsgenie_notification(monkeypatch, is_alert, priority, override_description, set_custom_fileds): post = MagicMock()
from datetime import datetime from mock import MagicMock from zmon_worker_monitor.zmon_worker.encoder import JsonDataEncoder from zmon_worker_monitor.zmon_worker.notifications.opsgenie import NotifyOpsgenie, NotificationError, get_user_agent URL_CREATE = 'https://api.opsgenie.com/v2/alerts' URL_CLOSE = 'https://api.opsgenie.com/v2/alerts/{}/close' API_KEY = '123' MESSAGE = 'ZMON ALERT' HEADERS = { 'User-Agent': get_user_agent(), 'Content-type': 'application/json', 'Authorization': 'GenieKey {}'.format(API_KEY), } @pytest.mark.parametrize('is_alert', (True, False)) def test_opsgenie_notification(monkeypatch, is_alert): post = MagicMock() monkeypatch.setattr('requests.post', post) alert = { 'alert_changed': True, 'changed': True, 'is_alert': is_alert,
from datetime import datetime from mock import MagicMock from zmon_worker_monitor.zmon_worker.encoder import JsonDataEncoder from zmon_worker_monitor.zmon_worker.notifications.opsgenie import NotifyOpsgenie, NotificationError, get_user_agent URL_CREATE = 'https://api.opsgenie.com/v1/json/alert' URL_CLOSE = 'https://api.opsgenie.com/v1/json/alert/close' API_KEY = '123' MESSAGE = 'ZMON ALERT' HEADERS = {'User-Agent': get_user_agent(), 'Content-type': 'application/json'} @pytest.mark.parametrize('is_alert', (True, False)) def test_opsgenie_notification(monkeypatch, is_alert): post = MagicMock() monkeypatch.setattr('requests.post', post) alert = { 'changed': True, 'is_alert': is_alert, 'alert_def': { 'id': 123 }, 'entity': {