当前位置: 首页>>代码示例>>Python>>正文


Python ElasticSearchCrashStorage.save_raw_and_processed方法代码示例

本文整理汇总了Python中socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage.save_raw_and_processed方法的典型用法代码示例。如果您正苦于以下问题:Python ElasticSearchCrashStorage.save_raw_and_processed方法的具体用法?Python ElasticSearchCrashStorage.save_raw_and_processed怎么用?Python ElasticSearchCrashStorage.save_raw_and_processed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage的用法示例。


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

示例1: test_success

# 需要导入模块: from socorro.external.elasticsearch.crashstorage import ElasticSearchCrashStorage [as 别名]
# 或者: from socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage import save_raw_and_processed [as 别名]
    def test_success(self, pyes_mock):
        mock_logging = mock.Mock()
        mock_es = mock.Mock()

        pyes_mock.ElasticSearch.return_value = mock_es
        required_config = ElasticSearchCrashStorage.get_required_config()
        required_config.add_option('logger', default=mock_logging)

        config_manager = ConfigurationManager(
            [required_config],
            app_name='testapp',
            app_version='1.0',
            app_description='app description',
            values_source_list=[{
                'logger': mock_logging,
                'elasticsearch_urls': 'http://elasticsearch_host:9200',
            }],
            argv_source=[]
        )

        with config_manager.context() as config:
            crash_id = a_processed_crash['uuid']

            es_storage = ElasticSearchCrashStorage(config)
            es_storage.save_raw_and_processed(
                a_raw_crash,
                None,
                a_processed_crash.copy(),
                crash_id,
            )

            expected_crash = {
                'crash_id': crash_id,
                'processed_crash': a_processed_crash.copy(),
                'raw_crash': a_raw_crash
            }

            expected_request_args = (
                'socorro201214',
                'crash_reports',
                expected_crash
            )
            expected_request_kwargs = {
                'id': crash_id,
                'replication': 'async',
            }

            mock_es.index.assert_called_with(
                *expected_request_args,
                **expected_request_kwargs
            )
开发者ID:FishingCactus,项目名称:socorro,代码行数:53,代码来源:test_crashstorage.py

示例2: test_success_after_limited_retry

# 需要导入模块: from socorro.external.elasticsearch.crashstorage import ElasticSearchCrashStorage [as 别名]
# 或者: from socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage import save_raw_and_processed [as 别名]
    def test_success_after_limited_retry(self, pyes_mock):
        mock_logging = mock.Mock()
        mock_es = mock.Mock()

        pyes_mock.ElasticSearch.return_value = mock_es
        required_config = ElasticSearchCrashStorage.get_required_config()
        required_config.add_option('logger', default=mock_logging)

        config_manager = ConfigurationManager(
            [required_config],
            app_name='testapp',
            app_version='1.0',
            app_description='app description',
            values_source_list=[{
                'logger': mock_logging,
                'elasticsearch_urls': 'http://elasticsearch_host:9200',
                'timeout': 0,
                'backoff_delays': [0, 0, 0],
                'transaction_executor_class':
                    TransactionExecutorWithLimitedBackoff
            }],
            argv_source=[]
        )

        with config_manager.context() as config:
            es_storage = ElasticSearchCrashStorage(config)

            esindex_results = [pyelasticsearch.exceptions.Timeout,
                               pyelasticsearch.exceptions.Timeout]

            def esindex_fn(*args, **kwargs):
                try:
                    r = esindex_results.pop(0)
                    raise r
                except IndexError:
                    return mock_es.index

            mock_es.index.side_effect = esindex_fn

            crash_id = a_processed_crash['uuid']

            es_storage.save_raw_and_processed(
                a_raw_crash,
                None,
                a_processed_crash.copy(),
                crash_id,
            )

            expected_crash = {
                'crash_id': crash_id,
                'processed_crash': a_processed_crash.copy(),
                'raw_crash': a_raw_crash
            }

            expected_request_args = (
                'socorro201214',
                'crash_reports',
                expected_crash
            )
            expected_request_kwargs = {
                'id': crash_id,
            }

            mock_es.index.assert_called_with(
                *expected_request_args,
                **expected_request_kwargs
            )
开发者ID:vivekkiran,项目名称:socorro-1,代码行数:69,代码来源:test_crashstorage.py


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