def test_comment_creation_failure(self, post_mock, get_mock, log_mock):
"""JiraOutput - Comment Creation, Failure"""
# setup successful search response
get_mock.return_value.status_code = 200
existing_issues = {'issues': [{'fields': {'summary': 'Bogus'}, 'id': '5000'}]}
get_mock.return_value.json.return_value = existing_issues
# setup successful auth, failed comment creation, and successful issue creation
type(post_mock.return_value).status_code = PropertyMock(side_effect=[200, 400, 200])
auth_resp = {'session': {'name': 'cookie_name', 'value': 'cookie_value'}}
post_mock.return_value.json.side_effect = [auth_resp, {'id': 6000}]
assert_true(self._dispatcher.dispatch(descriptor=self.DESCRIPTOR,
rule_name='rule_name',
alert=get_alert()))
log_mock.assert_called_with('Encountered an error when adding alert to existing Jira '
'issue %s. Attempting to create new Jira issue.', 5000)
评论列表
文章目录