Example #1
0
    def test_run_notifies_observers(self, mock_load, mock_jira_client):
        mock_jira_client.return_value = None
        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'
                mock_filter = Filter('assignee = "Bob"',
                                     namespace='pyccata.core')
                mock_filter.projectmanager = ProjectManager()
                mock_filter.projectmanager._client._client = DataProviders._get_client(
                )

                another_filter = Filter('assignee = "Bob"',
                                        namespace='pyccata.core')
                mock_filter.append(another_filter)

                mock_filter.run()
                self.assertEquals(mock_filter.failure, None)
                self.assertTrue(mock_filter.complete)
                self.assertEqual(
                    len(mock_filter.results),
                    len(DataProviders._test_data_for_search_results()))
                self.assertEqual(mock_filter._results, another_filter._results)
Example #2
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()))
Example #3
0
 def test_manager_returns_list_of_projects(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.projects()), 3)
Example #4
0
 def test_run_marks_thread_as_complete_on_success(self, mock_load,
                                                  mock_jira_client):
     mock_jira_client.return_value = None
     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'
             mock_filter = Filter('assignee = "Bob"',
                                  namespace='pyccata.core')
             mock_filter.projectmanager = ProjectManager()
             mock_filter.projectmanager._client._client = DataProviders._get_client(
             )
             mock_filter.run()
             self.assertTrue(mock_filter.complete)
             self.assertEqual(
                 len(mock_filter.results),
                 len(DataProviders._test_data_for_search_results()))
Example #5
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=[])