Example #1
0
    def test_run_observer_skips_observer_implementation_if_results_have_been_set(
            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')
                another_filter.projectmanager = mock_filter.projectmanager
                mock_filter.append(another_filter)

                mock_filter.run()
                self.assertTrue(mock_filter.complete)
                self.assertEqual(mock_filter._results, another_filter._results)
                another_filter.start()
                self.assertEqual(
                    len(mock_filter.results),
                    len(DataProviders._test_data_for_search_results()))
Example #2
0
 def test_run_raises_exception_if_query_fails(self, mock_load,
                                              mock_jira_client):
     mock_jira_client.return_value = DataProviders._get_client()
     mock_jira_client.search_issues.side_effect = InvalidQueryError(
         'The specified query is invalid')
     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('iamnotavalidquery',
                                  namespace='pyccata.core')
             mock_filter.projectmanager = ProjectManager()
             mock_filter.start()
             self.assertTrue(mock_filter.failed)
             self.assertIsInstance(mock_filter.failure, InvalidQueryError)
Example #3
0
 def test_run_raises_exception_if_manager_is_not_provided(self):
     mock_filter = Filter('issuetype = "Bug"', namespace='pyccata.core')
     mock_filter.start()
     self.assertTrue(mock_filter.failed)
     self.assertIsInstance(mock_filter.failure, AssertionError)