def test_execute_batches_pool_size_and_fills_on_complete(self, mock_query, mock_load, mock_jira_client): mock_query.side_effect = ArgumentValidationError('1st', 'append', 'pyccata.core.filter.Filter', 'object') mock_jira_client.return_value = DataProviders._get_client() 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 = ThreadManager() # start with 100 threads... for i in range(100): manager.append(ViableTestThread()) manager.start()
def test_execute_batches_pool_size_and_logs_on_error(self, mock_query, mock_load, mock_jira_client): mock_query.side_effect = ArgumentValidationError('1st', 'append', 'pyccata.core.filter.Filter', 'object') mock_jira_client.return_value = DataProviders._get_client() 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 = ThreadManager() test_threads = DataProviders.some_threads_explode() for thread in test_threads: manager.append(thread) manager.start()
def test_execute_adds_to_failures_when_all_observers_fail(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_broken = BrokenConnectionFilter('assignee = "Bob"') mock_filter = BrokenConnectionFilter('assignee = "Bob"') manager = ThreadManager() manager.append(mock_broken) manager.append(mock_filter) self.assertEquals(1, len(manager)) self.assertEquals(1, len(manager[0]._observers)) manager.start() self.assertEquals(1, len(manager._failed_threads))