def test_sum_field_multiple_sources(self, query_sum_mock): """ Test that the field is summed correctly and that involved issues are in the issue list. """ jira_filter = JiraFilter('http://jira/', 'username', 'password', field_name='customfield_11700') query_sum_mock.return_value = (0, ([])) jira_filter.sum_field('12345', '78910') self.assertTrue( query_sum_mock.has_calls([call('12345'), call('78910')]))
def test_sum_field_with_empty_jira_answer(self, get_query_url_mock): """ Test that the sum is -1 and the issue list is empty when jira returns empty json. """ jira_filter = JiraFilter('http://jira/', 'username', 'password', field_name='customfield_11700') get_query_url_mock.return_value = [] result, issue_list = jira_filter.sum_field('12345') get_query_url_mock.assert_called_once() self.assertEqual(-1, result) self.assertEqual([], issue_list)
def test_sum_field_when_no_issues(self, get_query_url_mock): """ Test that the sum is zero and the issue list is empty when there is no issues. """ jira_filter = JiraFilter('http://jira/', 'username', 'password', field_name='customfield_11700') get_query_url_mock.return_value = \ {"searchUrl": "http://jira/search", "viewUrl": "http://jira/view", "total": "5", "issues": []} result, issue_list = jira_filter.sum_field('12345') get_query_url_mock.assert_called_once() self.assertEqual(0, result) self.assertEqual([], issue_list)
def test_sum_field(self, get_query_url_mock): """ Test that the field is summed correctly and that involved issues are in the issue list. """ jira_filter = JiraFilter('http://jira/', 'username', 'password', field_name='customfield_11700') get_query_url_mock.return_value = \ {"searchUrl": "http://jira/search", "viewUrl": "http://jira/view", "total": "5", "issues": [ {"key": "ISS-1", "fields": {"summary": "First Issue", "customfield_11700": "20.3"}}, {"key": "ISS-2", "fields": {"summary": "2nd Issue", "customfield_11700": 100}}, {"key": "ISS-3", "fields": {"summary": "The Last Issue", "customfield_11700": None}}]} result, issue_list = jira_filter.sum_field('12345') get_query_url_mock.assert_called_once() self.assertEqual(120.3, result) self.assertEqual([{ "href": "http://jira/browse/ISS-1", "text": "First Issue" }, { "href": "http://jira/browse/ISS-2", "text": "2nd Issue" }], issue_list)