本文整理汇总了Python中arctic.store.version_store.VersionStore.read方法的典型用法代码示例。如果您正苦于以下问题:Python VersionStore.read方法的具体用法?Python VersionStore.read怎么用?Python VersionStore.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arctic.store.version_store.VersionStore
的用法示例。
在下文中一共展示了VersionStore.read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_version_allow_secondary_True
# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import read [as 别名]
def test_get_version_allow_secondary_True():
vs = create_autospec(VersionStore, instance=True,
_versions=Mock())
vs._allow_secondary = True
vs._find_snapshots.return_value = 'snap'
vs._versions.find.return_value = [{'_id': bson.ObjectId.from_datetime(dt(2013, 4, 1, 9, 0)),
'symbol': 's', 'version': 10}]
VersionStore.read(vs, "symbol")
assert vs._read_metadata.call_args_list == [call('symbol', as_of=None, read_preference=ReadPreference.NEAREST)]
assert vs._do_read.call_args_list == [call('symbol', vs._read_metadata.return_value, None, read_preference=ReadPreference.NEAREST)]
示例2: test_read_reports_random_errors
# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import read [as 别名]
def test_read_reports_random_errors():
self = create_autospec(VersionStore, _versions=Mock(), _arctic_lib=Mock(),
_allow_secondary=True)
self._collection = create_autospec(Collection)
self._do_read.__name__ = 'name' # feh: mongo_retry decorator cares about this
self._do_read.side_effect = Exception('bad')
with pytest.raises(Exception) as e:
with patch('arctic.store.version_store.log_exception') as le:
VersionStore.read(self, sentinel.symbol, sentinel.as_of, sentinel.from_version)
assert 'bad' in str(e)
assert le.call_count == 1
示例3: test_get_version_allow_secondary_user_override_False
# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import read [as 别名]
def test_get_version_allow_secondary_user_override_False():
"""Ensure user can override read preference when calling read"""
vs = create_autospec(VersionStore, instance=True,
_versions=Mock())
vs._allow_secondary = True
vs._find_snapshots.return_value = 'snap'
vs._versions.find.return_value = [{'_id': bson.ObjectId.from_datetime(dt(2013, 4, 1, 9, 0)),
'symbol': 's', 'version': 10}]
VersionStore.read(vs, "symbol", allow_secondary=False)
assert vs._read_metadata.call_args_list == [call('symbol', as_of=None, read_preference=ReadPreference.PRIMARY)]
assert vs._do_read.call_args_list == [call('symbol', vs._read_metadata.return_value, None, read_preference=ReadPreference.PRIMARY)]
示例4: test_read_handles_operation_failure
# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import read [as 别名]
def test_read_handles_operation_failure():
self = create_autospec(VersionStore, _versions=Mock(), _arctic_lib=Mock(),
_allow_secondary=True)
self._collection = create_autospec(Collection)
self._read_metadata.side_effect = [sentinel.meta1, sentinel.meta2]
self._read_metadata.__name__ = 'name'
self._do_read.__name__ = 'name' # feh: mongo_retry decorator cares about this
self._do_read.side_effect = [OperationFailure('error'), sentinel.read]
VersionStore.read(self, sentinel.symbol, sentinel.as_of, sentinel.from_version)
# Assert that, for the two read calls, the second uses the new metadata
assert self._do_read.call_args_list == [call(sentinel.symbol, sentinel.meta1, sentinel.from_version,
read_preference=ReadPreference.NEAREST)]
assert self._do_read_retry.call_args_list == [call(sentinel.symbol, sentinel.meta2, sentinel.from_version,
read_preference=ReadPreference.PRIMARY)]
示例5: test_read_handles_operation_failure
# 需要导入模块: from arctic.store.version_store import VersionStore [as 别名]
# 或者: from arctic.store.version_store.VersionStore import read [as 别名]
def test_read_handles_operation_failure():
self = Mock(spec=VersionStore)
self._read_preference.return_value = sentinel.read_preference
self._collection = create_autospec(Collection)
self._read_metadata.side_effect = [sentinel.meta1, sentinel.meta2]
self._read_metadata.__name__ = 'name'
self._do_read.__name__ = 'name' # feh: mongo_retry decorator cares about this
self._do_read.side_effect = [OperationFailure('error'), sentinel.read]
VersionStore.read(self, sentinel.symbol, sentinel.as_of,
from_version=sentinel.from_version,
date_range=sentinel.date_range,
other_kwarg=sentinel.other_kwarg)
# Assert that, for the two read calls, the second uses the new metadata
assert self._do_read.call_args_list == [call(sentinel.symbol, sentinel.meta1,
sentinel.from_version,
date_range=sentinel.date_range,
other_kwarg=sentinel.other_kwarg,
read_preference=sentinel.read_preference)]
assert self._do_read_retry.call_args_list == [call(sentinel.symbol, sentinel.meta2,
sentinel.from_version,
date_range=sentinel.date_range,
other_kwarg=sentinel.other_kwarg,
read_preference=ReadPreference.PRIMARY)]