Пример #1
0
    def test_manager_raises_invalid_connection_exception_if_search_query_fails(
            self, mock_load, mock_search, mock_jira_client):
        key = 'jira'
        mock_jira_client.return_value = None
        mock_search.side_effect = JIRAError(status_code=500,
                                            text='Server Error')

        data = DataProviders._test_data_for_search_results()
        with patch('pyccata.core.configuration.Configuration.manager',
                   new_callable=PropertyMock) as mock_manager:
            with patch(
                    'pyccata.core.configuration.Configuration._configuration',
                    new_callable=PropertyMock) as mock_config:
                mock_config.return_value = DataProviders._get_config_for_test()
                mock_manager.return_value = key
                manager = ProjectManager()
                self.assertIsInstance(manager.client.client, JIRA)
                with self.assertRaisesRegexp(
                        InvalidConnectionError,
                        'Recieved HTTP/500 whilst establishing.*'):
                    manager.search_issues(search_query='assignee = "bob123"',
                                          max_results=2,
                                          fields=[])
Пример #2
0
 def test_jira_attachments(self, mock_load, mock_search, mock_jira_client):
     data = DataProviders._test_data_for_attachments()
     mock_jira_client.return_value = None
     mock_search.return_value = data
     with patch('pyccata.core.configuration.Configuration.manager',
                new_callable=PropertyMock) as mock_manager:
         with patch(
                 'pyccata.core.configuration.Configuration._configuration',
                 new_callable=PropertyMock) as mock_config:
             mock_config.return_value = DataProviders._get_config_for_test()
             mock_manager.return_value = 'jira'
             manager = ProjectManager()
             self.assertIsInstance(manager.client.client, JIRA)
             attachments = manager.search_issues(
                 search_query='assignee = "bob123"',
                 max_results=2,
                 fields=['attachments'])
Пример #3
0
 def test_manager_returns_search_result_list(self, mock_load,
                                             mock_jira_client):
     key = 'jira'
     mock_jira_client.return_value = None
     data = DataProviders._test_data_for_search_results()
     with patch('pyccata.core.configuration.Configuration.manager',
                new_callable=PropertyMock) as mock_manager:
         with patch(
                 'pyccata.core.configuration.Configuration._configuration',
                 new_callable=PropertyMock) as mock_config:
             mock_config.return_value = DataProviders._get_config_for_test()
             mock_manager.return_value = key
             manager = ProjectManager()
             self.assertIsInstance(manager.client.client, JIRA)
             manager._client._client = DataProviders._get_client()
             self.assertEqual(
                 len(
                     manager.search_issues(
                         search_query='assignee = "bob123"',
                         max_results=2,
                         fields=[])),
                 len(DataProviders._test_data_for_search_results()))