• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python processor_app.ProcessorApp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中socorro.processor.processor_app.ProcessorApp的典型用法代码示例。如果您正苦于以下问题:Python ProcessorApp类的具体用法?Python ProcessorApp怎么用?Python ProcessorApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ProcessorApp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_transform_get_error_with_sentry_configured_successful

    def test_transform_get_error_with_sentry_configured_successful(
            self, mock_get_client, caplogpp):
        caplogpp.set_level('DEBUG')

        mock_client = mock.MagicMock()
        mock_client.captureException.return_value = 'someidentifier'
        mock_get_client.return_value = mock_client

        # Set up a processor and mock .get_raw_crash() to raise an exception
        config = self.get_standard_config(sentry_dsn='https://[email protected]/project')
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()

        expected_exception = ValueError('simulated error')
        pa.source.get_raw_crash.side_effect = expected_exception

        # The processor catches all exceptions from .get_raw_crash() and
        # .get_raw_dumps_as_files(), so there's nothing we need to catch here
        pa.transform('mycrashid')

        # Assert that the processor sent something to Sentry
        assert (
            mock_client.captureException.call_args_list == [
                mock.call((ValueError, expected_exception, WHATEVER))
            ]
        )

        # Assert that the logger logged the appropriate thing
        logging_msgs = [rec.message for rec in caplogpp.records]
        assert 'Error captured in Sentry! Reference: someidentifier' in logging_msgs
开发者ID:mozilla,项目名称:socorro,代码行数:30,代码来源:test_processor_app.py


示例2: test_transform_success

    def test_transform_success(self):
        config = self.get_standard_config()
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()

        fake_raw_crash = DotDict()
        mocked_get_raw_crash = mock.Mock(return_value=fake_raw_crash)
        pa.source.get_raw_crash = mocked_get_raw_crash

        fake_dump = {'upload_file_minidump': 'fake_dump_TEMPORARY.dump'}
        mocked_get_raw_dumps_as_files = mock.Mock(return_value=fake_dump)
        pa.source.get_raw_dumps_as_files = mocked_get_raw_dumps_as_files

        fake_processed_crash = DotDict()
        mocked_get_unredacted_processed = mock.Mock(return_value=fake_processed_crash)
        pa.source.get_unredacted_processed = mocked_get_unredacted_processed

        mocked_process_crash = mock.Mock(return_value=7)
        pa.processor.process_crash = mocked_process_crash
        pa.destination.save_processed = mock.Mock()
        finished_func = mock.Mock()
        with mock.patch('socorro.processor.processor_app.os.unlink') as mocked_unlink:
            # the call being tested
            pa.transform(17, finished_func)
        # test results
        mocked_unlink.assert_called_with('fake_dump_TEMPORARY.dump')
        pa.source.get_raw_crash.assert_called_with(17)
        pa.processor.process_crash.assert_called_with(
          fake_raw_crash,
          fake_dump,
          fake_processed_crash
        )
        pa.destination.save_raw_and_processed.assert_called_with(fake_raw_crash, None, 7, 17)
        eq_(finished_func.call_count, 1)
开发者ID:Tchanders,项目名称:socorro,代码行数:34,代码来源:test_processor_app.py


示例3: test_transform_polystorage_error_with_raven_configured_successful

    def test_transform_polystorage_error_with_raven_configured_successful(self, mock_raven):
        # Mock everything
        raven_mock_client = mock.MagicMock()
        raven_mock_client.captureException.return_value = 'someidentifier'
        mock_raven.Client.return_value = raven_mock_client

        # Set up a processor and mock out .save_raw_and_processed() with multiple
        # errors
        config = self.get_standard_config(sentry_dsn='https://[email protected]/project')
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        expected_exception = PolyStorageError()
        expected_exception.exceptions.append(NameError('waldo'))
        expected_exception.exceptions.append(AssertionError(False))
        pa.destination.save_raw_and_processed.side_effect = expected_exception

        # The important thing is that this is the exception that is raised and
        # not something from the raven error handling
        with pytest.raises(PolyStorageError):
            pa.transform('mycrashid')

        # Assert that we sent both exceptions to Sentry
        raven_mock_client.captureException.assert_has_calls(
            [mock.call(exc) for exc in expected_exception.exceptions]
        )

        # Assert that the logger logged the appropriate thing
        config.logger.info.assert_called_with(
            'Error captured in Sentry! Reference: someidentifier'
        )
开发者ID:stephendonner,项目名称:socorro,代码行数:33,代码来源:test_processor_app.py


示例4: test_transform_save_error_with_sentry_configured_successful

    def test_transform_save_error_with_sentry_configured_successful(
            self, mock_get_client, caplogpp):
        caplogpp.set_level('DEBUG')

        mock_client = mock.MagicMock()
        mock_client.captureException.return_value = 'someidentifier'
        mock_get_client.return_value = mock_client

        # Set up a processor and mock .save_raw_and_processed() to raise an exception
        config = self.get_standard_config(sentry_dsn='https://[email protected]/project')
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        expected_exception = ValueError('simulated error')
        pa.destination.save_raw_and_processed.side_effect = expected_exception

        # Run .transform() and make sure it raises the ValueError
        with pytest.raises(ValueError):
            pa.transform('mycrashid')

        # Assert that we sent the exception to Sentry
        assert (
            mock_client.captureException.call_args_list == [
                mock.call((ValueError, expected_exception, WHATEVER))
            ]
        )

        # Assert that the logger logged the appropriate thing
        logging_msgs = [rec.message for rec in caplogpp.records]
        assert 'Error captured in Sentry! Reference: someidentifier' in logging_msgs
开发者ID:mozilla,项目名称:socorro,代码行数:32,代码来源:test_processor_app.py


示例5: test_transform_save_error_with_raven_configured_successful

    def test_transform_save_error_with_raven_configured_successful(self, mock_raven):
        raven_mock_client = mock.MagicMock()
        raven_mock_client.captureException.return_value = 'someidentifier'
        mock_raven.Client.return_value = raven_mock_client

        # Set up a processor and mock .save_raw_and_processed() to raise an exception
        config = self.get_standard_config(sentry_dsn='https://[email protected]/project')
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        expected_exception = ValueError('simulated error')
        pa.destination.save_raw_and_processed.side_effect = expected_exception

        # Run .transform() and make sure it raises the ValueError
        with pytest.raises(ValueError):
            pa.transform('mycrashid')

        # Assert that we sent the exception to Sentry
        raven_mock_client.captureException.assert_called_once_with(expected_exception)

        # Assert that the logger logged the appropriate thing
        config.logger.info.assert_called_with(
            'Error captured in Sentry! Reference: someidentifier'
        )
开发者ID:stephendonner,项目名称:socorro,代码行数:26,代码来源:test_processor_app.py


示例6: test_transform_polystorage_error_with_raven_configured_failing

    def test_transform_polystorage_error_with_raven_configured_failing(self, mock_raven):
        raven_mock_client = mock.MagicMock()

        # Mock this to throw an error if it's called because it shouldn't get called
        raven_mock_client.captureException.side_effect = ValueError('raven error')
        mock_raven.Client.return_value = raven_mock_client

        # Set up processor and mock .save_raw_and_processed() to raise an exception
        config = self.get_standard_config(sentry_dsn='https://[email protected]/project')
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        expected_exception = PolyStorageError()
        expected_exception.exceptions.append(NameError('waldo'))
        expected_exception.exceptions.append(AssertionError(False))

        pa.destination.save_raw_and_processed.side_effect = expected_exception

        # Make sure the PolyStorageError is raised and not the error from
        # .captureException()
        with pytest.raises(PolyStorageError):
            pa.transform('mycrashid')

        # Assert that the logger logged raven isn't right
        config.logger.error.assert_called_with(
            'Unable to report error with Raven', exc_info=True
        )
开发者ID:stephendonner,项目名称:socorro,代码行数:29,代码来源:test_processor_app.py


示例7: test_transform_polystorage_error_without_raven_configured

    def test_transform_polystorage_error_without_raven_configured(self):
        config = self.get_standard_config()
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        def mocked_save_raw_and_processed(*_):
            exception = PolyStorageError()
            exception.exceptions.append(NameError('waldo'))
            raise exception

        pa.destination.save_raw_and_processed.side_effect = (
            mocked_save_raw_and_processed
        )
        # The important thing is that this is the exception that
        # is raised and not something from the raven error handling.
        assert_raises(
            PolyStorageError,
            pa.transform,
            'mycrashid'
        )

        config.logger.warning.assert_called_with(
            'Raven DSN is not configured and an exception happened'
        )
开发者ID:adngdb,项目名称:socorro,代码行数:26,代码来源:test_processor_app.py


示例8: test_transform_success

 def test_transform_success(self):
     config = self.get_standard_config()
     pa = ProcessorApp(config)
     pa._setup_source_and_destination()
     fake_raw_crash = DotDict()
     mocked_get_raw_crash = mock.Mock(return_value=fake_raw_crash)
     pa.source.get_raw_crash = mocked_get_raw_crash
     fake_dump = {'upload_file_minidump': 'fake dump'}
     mocked_get_raw_dumps_as_files = mock.Mock(return_value=fake_dump)
     pa.source.get_raw_dumps_as_files = mocked_get_raw_dumps_as_files
     mocked_convert_raw_crash_to_processed_crash = mock.Mock(return_value=7)
     pa.processor.convert_raw_crash_to_processed_crash = \
         mocked_convert_raw_crash_to_processed_crash
     pa.destination.save_processed = mock.Mock()
     finished_func = mock.Mock()
     # the call being tested
     pa.transform(17, finished_func)
     # test results
     pa.source.get_raw_crash.assert_called_with(17)
     pa.processor.convert_raw_crash_to_processed_crash.assert_called_with(
       fake_raw_crash,
       fake_dump
     )
     pa.destination.save_raw_and_processed.assert_called_with(fake_raw_crash, None, 7, 17)
     finished_func.assert_called_once()
开发者ID:GabiThume,项目名称:socorro,代码行数:25,代码来源:test_processor_app.py


示例9: test_setup

 def test_setup(self):
     config = self.get_standard_config()
     pa = ProcessorApp(config)
     pa._setup_source_and_destination()
     self.assertEqual(pa.registrar.id, 'mocked_registrar')
     self.assertEqual(pa.processor.id, 'mocked_processor')
     self.assertEqual(pa.waiting_func.id, 'mocked_registrar.checkin')
     self.assertEqual(pa.processor.id, 'mocked_processor')
开发者ID:GabiThume,项目名称:socorro,代码行数:8,代码来源:test_processor_app.py


示例10: test_source_iterator

 def test_source_iterator(self):
     config = self.get_standard_config()
     pa = ProcessorApp(config)
     pa._setup_source_and_destination()
     g = pa.source_iterator()
     eq_(g.next(), ((1,), {}))
     eq_(g.next(), ((2,), {}))
     eq_(g.next(), None)
     eq_(g.next(), ((3,), {}))
开发者ID:adngdb,项目名称:socorro,代码行数:9,代码来源:test_processor_app.py


示例11: test_source_iterator

 def test_source_iterator(self):
     config = self.get_standard_config()
     pa = ProcessorApp(config)
     pa._setup_source_and_destination()
     g = pa.source_iterator()
     assert g.next() == ((1,), {})
     assert g.next() == ((2,), {})
     assert g.next() is None
     assert g.next() == ((3,), {})
开发者ID:stephendonner,项目名称:socorro,代码行数:9,代码来源:test_processor_app.py


示例12: test_transform_unexpected_exception

    def test_transform_unexpected_exception(self):
        config = self.get_standard_config()
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        mocked_get_raw_crash = mock.Mock(side_effect=Exception("bummer"))
        pa.source.get_raw_crash = mocked_get_raw_crash

        pa.transform(17)
        pa.source.get_raw_crash.assert_called_with(17)
        pa.processor.reject_raw_crash.assert_called_with(17, "error in loading: bummer")
开发者ID:erikrose,项目名称:socorro,代码行数:10,代码来源:test_processor_app.py


示例13: test_transform_crash_id_missing

    def test_transform_crash_id_missing(self):
        config = self.get_standard_config()
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        mocked_get_raw_crash = mock.Mock(side_effect=CrashIDNotFound(17))
        pa.source.get_raw_crash = mocked_get_raw_crash

        pa.transform(17)
        pa.source.get_raw_crash.assert_called_with(17)
        pa.processor.reject_raw_crash.assert_called_with(17, "this crash cannot be found in raw crash storage")
开发者ID:erikrose,项目名称:socorro,代码行数:10,代码来源:test_processor_app.py


示例14: test_transform_polystorage_error_with_raven_configured_successful

    def test_transform_polystorage_error_with_raven_configured_successful(
        self,
        mock_raven,
    ):

        captured_exceptions = []  # a global

        def mock_capture_exception(exc_info=None):
            captured_exceptions.append(exc_info)
            return 'someidentifier'

        raven_mock_client = mock.MagicMock()
        raven_mock_client.captureException.side_effect = mock_capture_exception

        mock_raven.Client.return_value = raven_mock_client

        config = self.get_standard_config(
            sentry_dsn='https://[email protected]/project'
        )
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        def mocked_save_raw_and_processed(*_):
            exception = PolyStorageError()
            exception.exceptions.append(NameError('waldo'))
            exception.exceptions.append(AssertionError(False))
            raise exception

        pa.destination.save_raw_and_processed.side_effect = (
            mocked_save_raw_and_processed
        )
        # The important thing is that this is the exception that
        # is raised and not something from the raven error handling.
        assert_raises(
            PolyStorageError,
            pa.transform,
            'mycrashid'
        )

        config.logger.info.assert_called_with(
            'Error captured in Sentry! Reference: someidentifier'
        )
        eq_(len(captured_exceptions), 2)
        captured_exception, captured_exception_2 = captured_exceptions
        eq_(captured_exception.__class__, NameError)
        eq_(captured_exception.message, 'waldo')
        eq_(captured_exception_2.__class__, AssertionError)
        eq_(captured_exception_2.message, False)
开发者ID:adngdb,项目名称:socorro,代码行数:50,代码来源:test_processor_app.py


示例15: test_transform_unexpected_exception

    def test_transform_unexpected_exception(self):
        config = self.get_standard_config()
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        mocked_get_raw_crash = mock.Mock(side_effect=Exception('bummer'))
        pa.source.get_raw_crash = mocked_get_raw_crash

        finished_func = mock.Mock()
        pa.transform(17, finished_func)
        pa.source.get_raw_crash.assert_called_with(17)
        pa.processor.reject_raw_crash.assert_called_with(
            17,
            'error in loading: bummer'
        )
        eq_(finished_func.call_count, 1)
开发者ID:adngdb,项目名称:socorro,代码行数:15,代码来源:test_processor_app.py


示例16: test_transform_polystorage_error_with_sentry_configured_failing

    def test_transform_polystorage_error_with_sentry_configured_failing(
            self, mock_get_client, caplogpp):
        caplogpp.set_level('DEBUG')

        mock_client = mock.MagicMock()

        # Mock this to throw an error if it's called because it shouldn't get called
        mock_client.captureException.side_effect = ValueError('sentry error')
        mock_get_client.return_value = mock_client

        # Set up processor and mock .save_raw_and_processed() to raise an exception
        config = self.get_standard_config(sentry_dsn='https://[email protected]/project')
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        first_exc_info = (NameError, NameError('waldo'), 'fake tb 1')
        second_exc_info = (AssertionError, AssertionError(False), 'fake tb 2')
        expected_exception = PolyStorageError()
        expected_exception.exceptions.append(first_exc_info)
        expected_exception.exceptions.append(second_exc_info)
        pa.destination.save_raw_and_processed.side_effect = expected_exception

        # Make sure the PolyStorageError is raised and not the error from
        # .captureException()
        with pytest.raises(PolyStorageError):
            pa.transform('mycrashid')

        # Assert calls to logger--one set for each of the errors in
        # PolyStorageError
        expected = [
            ('Unable to report error with Raven', WHATEVER),
            ('Sentry DSN is not configured and an exception happened', None),
            ('Exception occurred', first_exc_info),
            ('error in processing or saving crash mycrashid', None),

            ('Unable to report error with Raven', WHATEVER),
            ('Sentry DSN is not configured and an exception happened', None),
            ('Exception occurred', second_exc_info),
            ('error in processing or saving crash mycrashid', None)
        ]
        actual = [(rec.message, rec.exc_info) for rec in caplogpp.records]

        assert actual == expected
开发者ID:mozilla,项目名称:socorro,代码行数:45,代码来源:test_processor_app.py


示例17: test_transform_polystorage_error_with_raven_configured_failing

    def test_transform_polystorage_error_with_raven_configured_failing(
        self,
        mock_raven,
    ):

        def mock_capture_exception(exc_info=None):
            raise ValueError('Someone is wrong on the Internet')

        raven_mock_client = mock.MagicMock()
        raven_mock_client.captureException.side_effect = mock_capture_exception

        mock_raven.Client.return_value = raven_mock_client

        config = self.get_standard_config(
            sentry_dsn='https://[email protected]/project'
        )
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        def mocked_save_raw_and_processed(*_):
            exception = PolyStorageError()
            exception.exceptions.append(NameError('waldo'))
            exception.exceptions.append(AssertionError(False))
            raise exception

        pa.destination.save_raw_and_processed.side_effect = (
            mocked_save_raw_and_processed
        )
        # The important thing is that this is the exception that
        # is raised and not something from the raven error handling.
        assert_raises(
            PolyStorageError,
            pa.transform,
            'mycrashid'
        )

        config.logger.error.assert_called_with(
            'Unable to report error with Raven', exc_info=True
        )
开发者ID:adngdb,项目名称:socorro,代码行数:41,代码来源:test_processor_app.py


示例18: test_transform_success

 def test_transform_success(self):
     config = self.get_standard_config()
     pa = ProcessorApp(config)
     pa._setup_source_and_destination()
     fake_raw_crash = DotDict()
     mocked_get_raw_crash = mock.Mock(return_value=fake_raw_crash)
     pa.source.get_raw_crash = mocked_get_raw_crash
     fake_dump = 'fake dump'
     mocked_get_raw_dump = mock.Mock(return_value=fake_dump)
     pa.source.get_raw_dump = mocked_get_raw_dump
     mocked_convert_raw_crash_to_processed_crash = mock.Mock(return_value=7)
     pa.processor.convert_raw_crash_to_processed_crash = \
         mocked_convert_raw_crash_to_processed_crash
     pa.destination.save_processed = mock.Mock()
     pa.transform(17)
     pa.source.get_raw_crash.assert_called_with(17)
     pa.source.get_raw_dump.assert_called_with(17)
     pa.processor.convert_raw_crash_to_processed_crash.assert_called_with(
       fake_raw_crash,
       fake_dump
     )
     pa.destination.save_processed.assert_called_with(7)
开发者ID:Meghashyamt,项目名称:socorro,代码行数:22,代码来源:test_processor_app.py


示例19: test_transform_polystorage_error_without_sentry_configured

    def test_transform_polystorage_error_without_sentry_configured(self, caplogpp):
        caplogpp.set_level('DEBUG')

        config = self.get_standard_config()
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()
        pa.source.get_raw_crash.return_value = DotDict({'raw': 'crash'})
        pa.source.get_raw_dumps_as_files.return_value = {}

        def mocked_save_raw_and_processed(*args, **kwargs):
            exception = PolyStorageError()
            exception.exceptions.append(NameError('waldo'))
            raise exception

        pa.destination.save_raw_and_processed.side_effect = mocked_save_raw_and_processed

        # The important thing is that this is the exception that
        # is raised and not something from the sentry error handling.
        with pytest.raises(PolyStorageError):
            pa.transform('mycrashid')

        logging_msgs = [rec.message for rec in caplogpp.records]
        assert 'Sentry DSN is not configured and an exception happened' in logging_msgs
开发者ID:mozilla,项目名称:socorro,代码行数:23,代码来源:test_processor_app.py


示例20: test_transform_get_error_with_raven_configured_successful

    def test_transform_get_error_with_raven_configured_successful(self, mock_raven):
        raven_mock_client = mock.MagicMock()
        raven_mock_client.captureException.return_value = 'someidentifier'
        mock_raven.Client.return_value = raven_mock_client

        # Set up a processor and mock .get_raw_crash() to raise an exception
        config = self.get_standard_config(sentry_dsn='https://[email protected]/project')
        pa = ProcessorApp(config)
        pa._setup_source_and_destination()

        expected_exception = ValueError('simulated error')
        pa.source.get_raw_crash.side_effect = expected_exception

        # The processor catches all exceptions from .get_raw_crash() and
        # .get_raw_dumps_as_files(), so there's nothing we need to catch here
        pa.transform('mycrashid')

        # Assert that the processor sent something to Sentry
        raven_mock_client.captureException.assert_called_once_with(expected_exception)

        # Assert that the logger logged the appropriate thing
        config.logger.info.assert_called_with(
            'Error captured in Sentry! Reference: someidentifier'
        )
开发者ID:stephendonner,项目名称:socorro,代码行数:24,代码来源:test_processor_app.py



注:本文中的socorro.processor.processor_app.ProcessorApp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python signature_utilities.JavaSignatureTool类代码示例发布时间:2022-05-27
下一篇:
Python legacy_processor.LegacyCrashProcessor类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap