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


Python VersionStore.restore_version方法代码示例

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


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

示例1: test_restore_version_insert_version_opfailure

# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import restore_version [as 别名]
def test_restore_version_insert_version_opfailure():
    vs = _create_mock_versionstore()
    vs._versions.insert_one.__name__ = 'insert_one'
    vs._versions.insert_one.side_effect = [OperationFailure('op failure'), None]
    VersionStore.restore_version(vs, symbol=TEST_SYMBOL,
                                 as_of=TPL_VERSION['version'], prune_previous_version=True)
    assert vs._version_nums.find_one_and_update.call_count == 1
    assert vs._versions.insert_one.call_count == 2
    assert vs._publish_change.call_count == 1
开发者ID:cozmacib,项目名称:arctic,代码行数:11,代码来源:test_version_store.py

示例2: test_restore_version_insert_version_dupkeyerror

# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import restore_version [as 别名]
def test_restore_version_insert_version_dupkeyerror():
    vs = _create_mock_versionstore()
    vs._versions.insert_one.__name__ = 'insert_one'
    vs._versions.insert_one.side_effect = [DuplicateKeyError('dup key error'), None]
    VersionStore.restore_version(vs, symbol=TEST_SYMBOL,
                                 as_of=TPL_VERSION['version'], prune_previous_version=True)
    assert vs._version_nums.find_one_and_update.call_count == 2
    assert vs._versions.insert_one.call_count == 2
    assert vs._publish_change.call_count == 1
开发者ID:cozmacib,项目名称:arctic,代码行数:11,代码来源:test_version_store.py

示例3: test_restore_version_data_missing_symbol

# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import restore_version [as 别名]
def test_restore_version_data_missing_symbol():
    vs = _create_mock_versionstore()
    vs._read_metadata.side_effect = NoDataFoundException("no data")
    with patch('arctic.store.version_store.mongo_retry') as mock_retry:
        mock_retry.side_effect = lambda f: f
        with pytest.raises(NoDataFoundException):
            VersionStore.restore_version(vs, symbol=TEST_SYMBOL,
                                         as_of=TPL_VERSION['version'], prune_previous_version=True)
    assert vs._read_metadata.call_args_list == [call(TEST_SYMBOL, as_of=TPL_VERSION['version'])]
    assert vs._versions.insert_one.called is False
开发者ID:manahl,项目名称:arctic,代码行数:12,代码来源:test_version_store.py

示例4: test_restore_version

# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import restore_version [as 别名]
def test_restore_version():
    vs = _create_mock_versionstore()

    LASTEST_VERSION = dict(TPL_VERSION, version=TPL_VERSION['version']+1, metadata={'something': 'different'})
    last_item = VersionedItem(symbol=TEST_SYMBOL, library=vs._arctic_lib.get_name(),
                              host=vs._arctic_lib.arctic.mongo_host,
                              version=LASTEST_VERSION, metadata=LASTEST_VERSION['metadata'], data="hello world")
    new_version = dict(LASTEST_VERSION, version=LASTEST_VERSION['version'] + 1)
    new_item = VersionedItem(symbol=TEST_SYMBOL, library=vs._arctic_lib.get_name(),
                             host=vs._arctic_lib.arctic.mongo_host,
                             version=new_version, metadata=new_version['metadata'], data=last_item.data)

    vs.write.return_value = new_item
    vs.read.return_value = last_item
    vs._read_metadata.side_effect = [TPL_VERSION, LASTEST_VERSION]

    with patch('arctic.store.version_store.bson.ObjectId') as mock_objId, \
            patch('arctic.store.version_store.mongo_retry') as mock_retry:
        mock_objId.return_value = MOCK_OBJID
        mock_retry.side_effect = lambda f: f
        ret_item = VersionStore.restore_version(vs, symbol=TEST_SYMBOL, as_of=LASTEST_VERSION['version'], prune_previous_version=True)
        assert ret_item == new_item
        assert vs._read_metadata.call_args_list == [call(TEST_SYMBOL, as_of=LASTEST_VERSION['version'])]
        assert vs._version_nums.find_one.call_args_list == [call({'symbol': TEST_SYMBOL})]
        assert vs.read.call_args_list == [call(TEST_SYMBOL, as_of=LASTEST_VERSION['version'])]
        assert vs.write.call_args_list == [call(TEST_SYMBOL, data=last_item.data, metadata=last_item.metadata, prune_previous_version=True)]
开发者ID:manahl,项目名称:arctic,代码行数:28,代码来源:test_version_store.py

示例5: test_restore_version

# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import restore_version [as 别名]
def test_restore_version():
    vs = _create_mock_versionstore()
    expected_new_version = TPL_VERSION.copy()
    expected_new_version.update({'_id': MOCK_OBJID,
                                 'version': TPL_VERSION['version'] + 1,
                                 'metadata': None})
    with patch('arctic.store.version_store.bson.ObjectId') as mock_objId, \
            patch('arctic.store.version_store.mongo_retry') as mock_retry:
        mock_objId.return_value = MOCK_OBJID
        mock_retry.side_effect = lambda f: f
        ret_val = VersionStore.restore_version(vs, symbol=TEST_SYMBOL, as_of=TPL_VERSION['version'], prune_previous_version=True)
        assert ret_val == VersionedItem(symbol=TEST_SYMBOL,
                                        library=vs._arctic_lib.get_name(),
                                        version=TPL_VERSION['version'] + 1,
                                        metadata=None,
                                        data=None)
        assert vs._versions.insert_one.call_args_list == [call(expected_new_version)]
        assert vs._publish_change.call_args_list == [call(TEST_SYMBOL, expected_new_version)]
开发者ID:cozmacib,项目名称:arctic,代码行数:20,代码来源:test_version_store.py

示例6: test_restore_last_version

# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import restore_version [as 别名]
def test_restore_last_version():
    vs = _create_mock_versionstore()
    vs._version_nums.find_one.return_value = {'version': TPL_VERSION['version']}

    vs._read_metadata.side_effect = [TPL_VERSION, TPL_VERSION]

    with patch('arctic.store.version_store.bson.ObjectId') as mock_objId, \
            patch('arctic.store.version_store.mongo_retry') as mock_retry:
        mock_objId.return_value = MOCK_OBJID
        mock_retry.side_effect = lambda f: f

        ret_item = VersionStore.restore_version(vs, symbol=TEST_SYMBOL, as_of=TPL_VERSION['version'],
                                               prune_previous_version=True)

        assert ret_item.version == TPL_VERSION['version']
        assert ret_item.metadata == TPL_VERSION.get('metadata')
        assert vs._read_metadata.call_args_list == [call(TEST_SYMBOL, as_of=TPL_VERSION['version'])]
        assert vs._version_nums.find_one.call_args_list == [call({'symbol': TEST_SYMBOL})]
        assert not vs.read.called
        assert not vs.write.called
开发者ID:manahl,项目名称:arctic,代码行数:22,代码来源:test_version_store.py


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