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


Python TestStore.put方法代码示例

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


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

示例1: setUp

# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import put [as 别名]
 def setUp(self):
     self.mixin = self.create_job_with_mixin({'CALCULATION_MODE': 'Hazard'},
                                             opensha.ClassicalMixin)
     # Store the canned result data in the KVS.
     key = self.mixin.job_id
     for realization in xrange(2):
         key = "%s/%s" % (self.mixin.job_id, realization + 1)
         TestStore.put(key, self.mock_results[realization])
         self.keys.append(key)
     LOG.debug("keys = '%s'" % self.keys)
     # Initialize the mixin instance.
     self.mixin.params = dict(NUMBER_OF_LOGIC_TREE_SAMPLES=2,
                              WIDTH_OF_MFD_BIN=1)
     self.mixin.calc = self.FakeLogicTreeProcessor()
     self.mixin.cache = dict()
开发者ID:dsg101,项目名称:openquake,代码行数:17,代码来源:hazard_classical_unittest.py

示例2: test_map_serializer_called_when_configured

# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import put [as 别名]
    def test_map_serializer_called_when_configured(self):
        """
        The quantile map serialization function is called when the
        POES parameter is specified in the configuration file.
        """
        def fake_serializer(*args):
            """Fake serialization function to be used in this test."""
            fake_serializer.number_of_calls += 1

        fake_serializer.number_of_calls = 0

        def fake_map_func(*args):
            return ["quantile_hazard_map!10!-122.9!38.0!0.2",
                    "quantile_hazard_map!10!-121.9!38.0!0.2",
                    "quantile_hazard_map!10!-122.8!38.0!0.4",
                    "quantile_hazard_map!10!-121.8!38.0!0.4"]

        key = TestStore.put(self.job_ctxt.job_id,
                            self.mock_results)
        self.keys.append(key)
        self.job_ctxt.params["POES"] = "0.6 0.8"
        self.calculator.do_quantiles(
            self.sites, 1, [0.2, 0.4],
            curve_serializer=lambda _, __: True,
            curve_task=test_data_reflector,
            map_func=fake_map_func,
            map_serializer=fake_serializer)
        # The serializer is called once for each quantile.
        self.assertEqual(2, fake_serializer.number_of_calls)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:31,代码来源:hazard_classical_test.py

示例3: setUp

# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import put [as 别名]
    def setUp(self):
        params = dict(
            CALCULATION_MODE='Hazard',
            SOURCE_MODEL_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_SRC_MODEL_LT,
            GMPE_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_GMPE_LT,
            BASE_PATH=SIMPLE_FAULT_BASE_PATH, OUTPUT_DIR="output",
            NUMBER_OF_LOGIC_TREE_SAMPLES=2, WIDTH_OF_MFD_BIN=1)

        self.job_ctxt = create_job(params, job_id=99)
        self.calculator = classical.ClassicalHazardCalculator(self.job_ctxt)

        # Store the canned result data in the KVS.
        key = self.job_ctxt.job_id
        for realization in xrange(2):
            key = "%s/%s" % (self.job_ctxt.job_id, realization + 1)
            TestStore.put(key, self.mock_results[realization])
            self.keys.append(key)
        LOG.debug("keys = '%s'" % self.keys)

        self.calculator.calc = self.FakeLogicTreeProcessor()
        self.calculator.cache = dict()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:23,代码来源:hazard_classical_test.py

示例4: test_curve_serializer_called_when_passed

# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import put [as 别名]
    def test_curve_serializer_called_when_passed(self):
        """The passed quantile curve serialization function is called."""

        def fake_serializer(**kwargs):
            """Fake serialization function to be used in this test."""
            fake_serializer.number_of_calls += 1

        fake_serializer.number_of_calls = 0

        key = TestStore.put(self.job_ctxt.job_id, self.mock_results)
        self.keys.append(key)
        self.calculator.do_quantiles(
            self.sites, 1, [0.2, 0.4], curve_serializer=fake_serializer,
            curve_task=test_async_data_reflector)
        # The serializer is called only once (for all quantiles).
        self.assertEqual(1, fake_serializer.number_of_calls)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:18,代码来源:hazard_classical_test.py

示例5: test_missing_map_serializer_assertion

# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import put [as 别名]
    def test_missing_map_serializer_assertion(self):
        """
        When the quantile map serialization function is not set an
        `AssertionError` is raised.

        TODO: once everyone is on python rev. > 2.7 extend the test to check
        for the specific assertion message.
        """

        key = TestStore.put(self.job_ctxt.job_id, self.mock_results)
        self.keys.append(key)
        self.job_ctxt.params["POES"] = "0.6 0.8"
        self.assertRaises(
            AssertionError, self.calculator.do_quantiles,
            self.sites, 1, [0.5],
            curve_serializer=lambda _, __: True,
            curve_task=test_data_reflector, map_func=lambda _: [1, 2, 3])
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:19,代码来源:hazard_classical_test.py

示例6: test_missing_map_function_assertion

# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import put [as 别名]
    def test_missing_map_function_assertion(self):
        """
        When the mean map calculation function is not set an `AssertionError`
        is raised.

        TODO: once everyone is on python rev. > 2.7 extend the test to check
        for the specific assertion message.
        """

        key = TestStore.put(self.mixin.job_id, self.mock_results)
        self.keys.append(key)
        self.mixin.params["POES"] = "0.6 0.8"
        self.assertRaises(
            AssertionError, self.mixin.do_means,
            self.sites, 1,
            curve_serializer=lambda _: True, curve_task=test_data_reflector,
            map_serializer=lambda _: True, map_func=None)
开发者ID:dsg101,项目名称:openquake,代码行数:19,代码来源:hazard_classical_unittest.py

示例7: test_map_serializer_not_called_unless_configured

# 需要导入模块: from tests.utils.helpers import TestStore [as 别名]
# 或者: from tests.utils.helpers.TestStore import put [as 别名]
    def test_map_serializer_not_called_unless_configured(self):
        """
        The mean map serialization function is not called unless the
        POES parameter was specified in the configuration file.
        """

        def fake_serializer(kvs_keys):
            """Fake serialization function to be used in this test."""
            # Check that the data returned is the one we expect for the current
            # realization.
            fake_serializer.number_of_calls += 1

        fake_serializer.number_of_calls = 0

        key = TestStore.put(self.job_ctxt.job_id, self.mock_results)
        self.keys.append(key)
        self.calculator.do_means(self.sites, 1,
                        curve_serializer=lambda _: True,
                        curve_task=test_data_reflector)
        self.assertEqual(0, fake_serializer.number_of_calls)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:22,代码来源:hazard_classical_test.py


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