本文整理汇总了Python中socorro.external.es.crashstorage.ESCrashStorage.get_index_for_crash方法的典型用法代码示例。如果您正苦于以下问题:Python ESCrashStorage.get_index_for_crash方法的具体用法?Python ESCrashStorage.get_index_for_crash怎么用?Python ESCrashStorage.get_index_for_crash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.external.es.crashstorage.ESCrashStorage
的用法示例。
在下文中一共展示了ESCrashStorage.get_index_for_crash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_index_for_crash_dynamic_name
# 需要导入模块: from socorro.external.es.crashstorage import ESCrashStorage [as 别名]
# 或者: from socorro.external.es.crashstorage.ESCrashStorage import get_index_for_crash [as 别名]
def test_get_index_for_crash_dynamic_name(self):
"""Test a dynamic (date-based) index name.
"""
# The crashstorage class looks for '%' in the index name; if that
# symbol is present, it will attempt to generate a new date-based
# index name. Since the test base config doesn't use this pattern,
# we need to specify it now.
modified_config = self.get_tuned_config(
ESCrashStorage,
{'resource.elasticsearch.elasticsearch_index':
'socorro_integration_test_reports%Y%m%d'}
)
es_storage = ESCrashStorage(config=modified_config)
# The date is used to generate the name of the index; it must be a
# datetime object.
date = string_to_datetime(
a_processed_crash['client_crash_date']
)
index = es_storage.get_index_for_crash(date)
# The base index name is obtained from the test base class and the
# date is appended to it according to pattern specified above.
ok_(type(index) is str)
eq_(index, 'socorro_integration_test_reports20120408')
示例2: test_get_index_for_crash_static_name
# 需要导入模块: from socorro.external.es.crashstorage import ESCrashStorage [as 别名]
# 或者: from socorro.external.es.crashstorage.ESCrashStorage import get_index_for_crash [as 别名]
def test_get_index_for_crash_static_name(self):
"""Test a static index name """
es_storage = ESCrashStorage(config=self.config)
# The actual date isn't important since the index name won't use it.
index = es_storage.get_index_for_crash('some_date')
# The index name is obtained from the test base class.
assert type(index) is str
assert index == 'socorro_integration_test_reports'