def test_issues_with_field_without_issues(self, get_query_url_mock): """ Test that the issue list is empty when there are 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": []} issue_list = jira_filter.issues_with_field('12345') get_query_url_mock.assert_called_once() self.assertEqual([], issue_list)
def test_issues_with_field_with_empty_jira_answer(self, get_query_url_mock, mock_error): """ Test that 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 = [] issue_list = jira_filter.issues_with_field('12345') get_query_url_mock.assert_called_once() self.assertEqual([], issue_list) self.assertEqual("Couldn't get issues from Jira filter %s: %s.", mock_error.call_args_list[0][0][0]) self.assertEqual("12345", mock_error.call_args_list[0][0][1]) self.assertIsInstance(mock_error.call_args_list[0][0][2], TypeError)
def test_issues_with_field_without_issues(self, get_query_url_mock): """ Test that the issue list is empty when there are 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": []} issue_list = jira_filter.issues_with_field('12345') get_query_url_mock.assert_called_once() self.assertEqual([], issue_list)
def test_issues_with_field_with_empty_jira_answer(self, get_query_url_mock): """ Test that 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 = [] issue_list = jira_filter.issues_with_field('12345') get_query_url_mock.assert_called_once() self.assertEqual([], issue_list)
def test_issues_with_field(self, get_query_url_mock): """ Test that the issues are returned correctly with their field values. """ 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}}]} issue_list = jira_filter.issues_with_field('12345') get_query_url_mock.assert_called_once() self.assertEqual([ ({"href": "http://jira/browse/ISS-1", "text": "First Issue"}, 20.3), ({"href": "http://jira/browse/ISS-2", "text": "2nd Issue"}, 100.0) ], issue_list)
def test_issues_with_field_with_empty_jira_answer(self, get_query_url_mock, mock_error): """ Test that 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 = [] issue_list = jira_filter.issues_with_field('12345') get_query_url_mock.assert_called_once() self.assertEqual([], issue_list) self.assertEqual("Couldn't get issues from Jira filter %s: %s.", mock_error.call_args_list[0][0][0]) self.assertEqual("12345", mock_error.call_args_list[0][0][1]) self.assertIsInstance(mock_error.call_args_list[0][0][2], TypeError)
def test_issues_with_field(self, get_query_url_mock): """ Test that the issues are returned correctly with their field values. """ 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}}]} issue_list = jira_filter.issues_with_field('12345') get_query_url_mock.assert_called_once() self.assertEqual([({ "href": "http://jira/browse/ISS-1", "text": "First Issue" }, 20.3), ({ "href": "http://jira/browse/ISS-2", "text": "2nd Issue" }, 100.0)], issue_list)