def test_nr_issues_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.nr_issues('12345', '78910') self.assertTrue(query_sum_mock.has_calls([call('12345'), call('78910')]))
def test_nr_issues_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.nr_issues('12345', '78910') self.assertTrue( query_sum_mock.has_calls([call('12345'), call('78910')]))
def test_nr_issues_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.nr_issues('12345') get_query_url_mock.assert_called_once() self.assertEqual(-1, result) self.assertEqual([], issue_list)
def test_nr_issues_when_no_issues(self, get_query_url_mock): """ Test that the number of issues 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": "0", "issues": []} result, issue_list = jira_filter.nr_issues('12345') get_query_url_mock.assert_called_once() self.assertEqual(0, result) # pay attention, it reads 'total' and does not count the issues self.assertEqual([], issue_list)
def test_nr_issues_when_no_issues(self, get_query_url_mock): """ Test that the number of issues 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": "0", "issues": []} result, issue_list = jira_filter.nr_issues('12345') get_query_url_mock.assert_called_once() self.assertEqual( 0, result ) # pay attention, it reads 'total' and does not count the issues self.assertEqual([], issue_list)
def test_nr_issues(self, get_query_url_mock): """ Test that the number of items equals the sum of totals per metric source returned by Jira. """ 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}}]} result, issue_list = jira_filter.nr_issues('12345') get_query_url_mock.assert_called_once() self.assertEqual(5, result) # pay attention, it reads 'total' and does not count the issues self.assertEqual([ {"href": "http://jira/browse/ISS-1", "text": "First Issue"}, {"href": "http://jira/browse/ISS-2", "text": "2nd Issue"} ], issue_list)
def test_nr_issues(self, get_query_url_mock): """ Test that the number of items equals the sum of totals per metric source returned by Jira. """ 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}}]} result, issue_list = jira_filter.nr_issues('12345') get_query_url_mock.assert_called_once() self.assertEqual( 5, result ) # pay attention, it reads 'total' and does not count the issues self.assertEqual([{ "href": "http://jira/browse/ISS-1", "text": "First Issue" }, { "href": "http://jira/browse/ISS-2", "text": "2nd Issue" }], issue_list)