def test_rocketchat_getinfo(): rule = { 'name': 'Test Rule', 'type': 'any', 'rocket_chat_webhook_url': 'http://please.dontgohere.rocketchat', 'alert_subject': 'Cool subject', 'alert': [] } rules_loader = FileRulesLoader({}) rules_loader.load_modules(rule) alert = RocketChatAlerter(rule) expected_data = { 'type': 'rocketchat', 'rocket_chat_username_override': 'elastalert2', 'rocket_chat_webhook_url': ['http://please.dontgohere.rocketchat'] } actual_data = alert.get_info() assert expected_data == actual_data
def test_rocketchat_required_error(rocket_chat_webhook_url, expected_data): try: rule = { 'name': 'Test Rule', 'type': 'any', 'alert_subject': 'Cool subject', 'alert': [] } if rocket_chat_webhook_url: rule['rocket_chat_webhook_url'] = rocket_chat_webhook_url rules_loader = FileRulesLoader({}) rules_loader.load_modules(rule) alert = RocketChatAlerter(rule) actual_data = alert.get_info() assert expected_data == actual_data except Exception as ea: assert expected_data in str(ea)