test_alerters.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:doorman 作者: mwielgoszewski 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号