Пример #1
0
 def test_get_issues_returns_JIRAError(self, mock_remaining_issues: Mock, mock_JIRA_client: Mock) -> None:
     mock_JIRA_client.return_value.get_issues.side_effect = JIRAError('Some exception')
     mock_remaining_issues.return_value = 0
     with app.test_request_context():
         try:
             jira_client = JiraClient(issue_labels=[],
                                      issue_tracker_url=app.config['ISSUE_TRACKER_URL'],
                                      issue_tracker_user=app.config['ISSUE_TRACKER_USER'],
                                      issue_tracker_password=app.config['ISSUE_TRACKER_PASSWORD'],
                                      issue_tracker_project_id=app.config['ISSUE_TRACKER_PROJECT_ID'],
                                      issue_tracker_max_results=app.config['ISSUE_TRACKER_MAX_RESULTS'])
             jira_client.get_issues('key')
         except JIRAError as e:
             self.assertTrue(type(e), type(JIRAError))
             self.assertTrue(e, 'Some exception')
Пример #2
0
 def test_get_issues_returns_issues(self, mock_sort_issues: Mock,
                                    mock_get_url: Mock,
                                    mock_get_issue_properties: Mock,
                                    mock_JIRA_client: Mock) -> None:
     mock_JIRA_client.return_value.search_issues.return_value = self.mock_jira_issues
     mock_get_issue_properties.return_value = self.mock_issue
     mock_get_url.return_value = 'url'
     mock_sort_issues.return_value = [self.mock_issue]
     with app.test_request_context():
         jira_client = JiraClient(
             issue_labels=[],
             issue_tracker_url=app.config['ISSUE_TRACKER_URL'],
             issue_tracker_user=app.config['ISSUE_TRACKER_USER'],
             issue_tracker_password=app.config['ISSUE_TRACKER_PASSWORD'],
             issue_tracker_project_id=app.
             config['ISSUE_TRACKER_PROJECT_ID'],
             issue_tracker_max_results=app.
             config['ISSUE_TRACKER_MAX_RESULTS'])
         results = jira_client.get_issues(table_uri='key')
         mock_JIRA_client.assert_called()
         self.assertEqual(results.issues[0], self.mock_issue)
         self.assertEqual(results.total, self.mock_jira_issues.total)
         mock_JIRA_client.return_value.search_issues.assert_has_calls([
             call(SEARCH_STUB_ALL_ISSUES.format(table_key="key"),
                  maxResults=3),
             call(SEARCH_STUB_OPEN_ISSUES.format(table_key="key"),
                  maxResults=1)
         ])
 def test_get_issues_returns_issues(self, mock_get_url: Mock,
                                    mock_get_issue_properties: Mock,
                                    mock_JIRA_client: Mock) -> None:
     mock_JIRA_client.return_value.search_issues.return_value = self.mock_jira_issues
     mock_get_issue_properties.return_value = self.mock_issue
     mock_get_url.return_value = 'url'
     with app.test_request_context():
         jira_client = JiraClient(
             issue_tracker_url=app.config['ISSUE_TRACKER_URL'],
             issue_tracker_user=app.config['ISSUE_TRACKER_USER'],
             issue_tracker_password=app.config['ISSUE_TRACKER_PASSWORD'],
             issue_tracker_project_id=app.
             config['ISSUE_TRACKER_PROJECT_ID'],
             issue_tracker_max_results=app.
             config['ISSUE_TRACKER_MAX_RESULTS'])
         results = jira_client.get_issues(table_uri='key')
         mock_JIRA_client.assert_called
         self.assertEqual(results.issues[0], self.mock_issue)
         self.assertEqual(results.remaining, self.mock_jira_issues.total)
         mock_JIRA_client.return_value.search_issues.assert_called_with(
             'text ~ "key" AND resolution = Unresolved order by createdDate DESC',
             maxResults=3)