def test_dispatch_success_good_policy(self, get_mock, post_mock, log_mock):
"""PagerDutyIncidentOutput - Dispatch Success, Good Policy"""
# /users, /escalation_policies, /services
type(get_mock.return_value).status_code = PropertyMock(side_effect=[200, 200, 200])
json_user = {'users': [{'id': 'user_id'}]}
json_policy = {'escalation_policies': [{'id': 'policy_id'}]}
json_service = {'services': [{'id': 'service_id'}]}
get_mock.return_value.json.side_effect = [json_user, json_policy, json_service]
# /incidents
post_mock.return_value.status_code = 200
ctx = {'pagerduty-incident': {'assigned_policy': 'valid_policy'}}
assert_true(self._dispatcher.dispatch(descriptor=self.DESCRIPTOR,
rule_name='rule_name',
alert=get_alert(context=ctx)))
log_mock.assert_called_with('Successfully sent alert to %s', self.SERVICE)
评论列表
文章目录