def test_nr_issues_with_field_empty_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_with_field_empty('12345', '78910') self.assertTrue(query_sum_mock.has_calls([call('12345'), call('78910')]))
def test_nr_issues_with_field_empty_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_with_field_empty('12345', '78910') self.assertTrue( query_sum_mock.has_calls([call('12345'), call('78910')]))
def test_nr_issues_with_field_empty_and_empty_jira(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_with_field_empty('12345') get_query_url_mock.assert_called_once() self.assertEqual(-1, result) self.assertEqual([], issue_list)
def test_nr_issues_with_field_empty_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": "5", "issues": []} result, issue_list = jira_filter.nr_issues_with_field_empty('12345') get_query_url_mock.assert_called_once() self.assertEqual(0, result) self.assertEqual([], issue_list)
def test_nr_issues_with_field_omitted(self, get_query_url_mock): """ Test that the number of items equals those that do not have specified field. """ 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"}}, {"key": "ISS-2", "fields": {"summary": "2nd Issue", "customfield_11700": 100}}]} result, issue_list = jira_filter.nr_issues_with_field_empty('12345') get_query_url_mock.assert_called_once() self.assertEqual(1, result) self.assertEqual([{"href": "http://jira/browse/ISS-1", "text": "First Issue"}], issue_list)
def test_nr_issues_with_field_empty_and_empty_jira(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_with_field_empty('12345') get_query_url_mock.assert_called_once() self.assertEqual(-1, result) self.assertEqual([], issue_list)
def test_nr_issues_with_field_empty_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": "5", "issues": []} result, issue_list = jira_filter.nr_issues_with_field_empty('12345') get_query_url_mock.assert_called_once() self.assertEqual(0, result) self.assertEqual([], issue_list)
def test_nr_issues_with_field_omitted(self, get_query_url_mock): """ Test that the number of items equals those that do not have specified field. """ 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"}}, {"key": "ISS-2", "fields": {"summary": "2nd Issue", "customfield_11700": 100}}]} result, issue_list = jira_filter.nr_issues_with_field_empty('12345') get_query_url_mock.assert_called_once() self.assertEqual(1, result) self.assertEqual([{ "href": "http://jira/browse/ISS-1", "text": "First Issue" }], issue_list)