本文整理汇总了Python中arctic.store.bson_store.BSONStore类的典型用法代码示例。如果您正苦于以下问题:Python BSONStore类的具体用法?Python BSONStore怎么用?Python BSONStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BSONStore类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_index_information
def test_index_information():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True)
arctic_lib.get_top_level_collection.return_value = collection
bsons = BSONStore(arctic_lib)
bsons.index_information()
assert collection.index_information.call_count == 1
示例2: test_enable_sharding
def test_enable_sharding():
arctic_lib = create_autospec(ArcticLibraryBinding)
arctic_lib.arctic = create_autospec(Arctic)
with patch('arctic.store.bson_store.enable_sharding', autospec=True) as enable_sharding:
arctic_lib.get_top_level_collection.return_value.database.create_collection.__name__ = 'some_name'
arctic_lib.get_top_level_collection.return_value.database.collection_names.__name__ = 'some_name'
bsons = BSONStore(arctic_lib)
bsons.enable_sharding()
# Check we always set the sharding to be hashed.
assert enable_sharding.call_args_list == [call(arctic_lib.arctic, arctic_lib.get_name(), hashed=True, key='_id')]
示例3: test_drop_index
def test_drop_index():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True)
arctic_lib.get_top_level_collection.return_value = collection
bsons = BSONStore(arctic_lib)
bsons.drop_index(sentinel.name)
assert collection.drop_index.call_count == 1
assert collection.drop_index.call_args_list == [call(sentinel.name)]
示例4: test_create_index
def test_create_index():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True)
arctic_lib.get_top_level_collection.return_value = collection
bsons = BSONStore(arctic_lib)
bsons.create_index([(sentinel.path1, sentinel.order1), (sentinel.path2, sentinel.path2)])
assert collection.create_index.call_count == 1
assert collection.create_index.call_args_list == [call([(sentinel.path1, sentinel.order1), (sentinel.path2, sentinel.path2)])]
示例5: test_count
def test_count():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True, count=Mock(), count_documents=Mock())
arctic_lib.get_top_level_collection.return_value = collection
bsons = BSONStore(arctic_lib)
bsons.count(sentinel.filter)
assert collection.count.call_count + collection.count_documents.call_count == 1
assert collection.count.call_args_list == [call(filter=sentinel.filter)] or collection.count_documents.call_args_list == [call(filter=sentinel.filter)]
示例6: test_find_one_and_delete
def test_find_one_and_delete():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True)
arctic_lib.get_top_level_collection.return_value = collection
ms = BSONStore(arctic_lib)
ms.find_one_and_delete(sentinel.filter)
assert collection.find_one_and_delete.call_count == 1
assert collection.find_one_and_delete.call_args_list == [call(sentinel.filter)]
示例7: test_update_many
def test_update_many():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True)
arctic_lib.get_top_level_collection.return_value = collection
bsons = BSONStore(arctic_lib)
bsons.update_many(sentinel.filter, sentinel.replacements)
assert arctic_lib.check_quota.call_count == 1
assert collection.update_many.call_count == 1
assert collection.update_many.call_args_list == [call(sentinel.filter, sentinel.replacements)]
示例8: test_insert_one
def test_insert_one():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True)
arctic_lib.get_top_level_collection.return_value = collection
bsons = BSONStore(arctic_lib)
bsons.insert_one(sentinel.document)
assert arctic_lib.check_quota.call_count == 1
assert collection.insert_one.call_count == 1
assert collection.insert_one.call_args_list == [call(sentinel.document)]
示例9: test_find
def test_find():
arctic_lib = create_autospec(ArcticLibraryBinding, instance=True)
collection = create_autospec(Collection, instance=True)
collection.find.return_value = (doc for doc in [sentinel.document])
arctic_lib.get_top_level_collection.return_value = collection
bsons = BSONStore(arctic_lib)
assert list(bsons.find(sentinel.filter)) == [sentinel.document]
assert collection.find.call_count == 1
assert collection.find.call_args_list == [call(sentinel.filter)]
示例10: test_initialize_library
def test_initialize_library():
arctic_lib = create_autospec(ArcticLibraryBinding)
arctic_lib.arctic = create_autospec(Arctic)
with patch('arctic.store.bson_store.enable_sharding', autospec=True) as enable_sharding:
arctic_lib.get_top_level_collection.return_value.database.create_collection.__name__ = 'some_name'
arctic_lib.get_top_level_collection.return_value.database.collection_names.__name__ = 'some_name'
BSONStore.initialize_library(arctic_lib, hashed=True)
BSONStore.initialize_library(arctic_lib, hashed=False)
# Check we always set the sharding to be hashed, regarless of user input
assert enable_sharding.call_args_list == [call(arctic_lib.arctic, arctic_lib.get_name(), hashed=True, key='_id'),
call(arctic_lib.arctic, arctic_lib.get_name(), hashed=True, key='_id')]