def test_issue_creation_failure(self, post_mock, get_mock, log_mock):
"""JiraOutput - Issue Creation, Failure"""
# setup the successful search response - no results
get_mock.return_value.status_code = 200
get_mock.return_value.json.return_value = {'issues': []}
# setup successful auth response and failed issue creation
type(post_mock.return_value).status_code = PropertyMock(side_effect=[200, 400])
auth_resp = {'session': {'name': 'cookie_name', 'value': 'cookie_value'}}
post_mock.return_value.content = 'some bad content'
post_mock.return_value.json.side_effect = [auth_resp, dict()]
assert_false(self._dispatcher.dispatch(descriptor=self.DESCRIPTOR,
rule_name='rule_name',
alert=get_alert()))
log_mock.assert_called_with('Failed to send alert to %s', self.SERVICE)
评论列表
文章目录