def test_will_alert(self, node, rule, testapp):
match = RuleMatch(
rule=rule,
node=node.to_dict(),
result={
'name': 'foo',
'action': 'added',
'timestamp': dt.datetime.utcnow(),
'columns': {'boo': 'baz', 'kung': 'bloo'},
}
)
with mock.patch.object(raven.Client, 'captureMessage', return_value=None) as pmock:
alerter = SentryAlerter(self.config)
alerter.handle_alert(node.to_dict(), match)
assert pmock.called
_, kwargs = pmock.call_args
assert kwargs['message'] == rule.template.safe_substitute(
match.result['columns'],
**node.to_dict()
).rstrip()
评论列表
文章目录