當前位置: 首頁>>代碼示例>>Python>>正文


Python bson_store.BSONStore類代碼示例

本文整理匯總了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
開發者ID:manahl,項目名稱:arctic,代碼行數:9,代碼來源:test_bson_store.py

示例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')]
開發者ID:manahl,項目名稱:arctic,代碼行數:10,代碼來源:test_bson_store.py

示例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)]
開發者ID:manahl,項目名稱:arctic,代碼行數:10,代碼來源:test_bson_store.py

示例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)])]
開發者ID:manahl,項目名稱:arctic,代碼行數:10,代碼來源:test_bson_store.py

示例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)]
開發者ID:manahl,項目名稱:arctic,代碼行數:10,代碼來源:test_bson_store.py

示例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)]
開發者ID:manahl,項目名稱:arctic,代碼行數:10,代碼來源:test_bson_store.py

示例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)]
開發者ID:manahl,項目名稱:arctic,代碼行數:11,代碼來源:test_bson_store.py

示例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)]
開發者ID:manahl,項目名稱:arctic,代碼行數:11,代碼來源:test_bson_store.py

示例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)]
開發者ID:manahl,項目名稱:arctic,代碼行數:11,代碼來源:test_bson_store.py

示例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')]
開發者ID:pchavanne,項目名稱:arctic,代碼行數:11,代碼來源:test_bson_store.py


注:本文中的arctic.store.bson_store.BSONStore類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。