示例#1
0
async def test_docs_on_deleted(filled_database: Database) -> None:
    doc = await filled_database["foo"]
    await doc.delete()

    with pytest.raises(KeyError):
        async for doc in filled_database.docs(["foo"]):
            assert False

    async for doc in filled_database.docs(["foo"], create=True):
        assert doc.id == "foo"
        assert doc.exists is False
示例#2
0
async def test_docs_on_non_existant(database: Database) -> None:
    docs = [doc async for doc in database.docs(["foo"], create=True)]

    assert len(docs) == 1
    doc = docs[0]
    assert doc._dirty_cache is True
    assert doc.id == "foo"
示例#3
0
async def test_docs_contain_ddocs_with_param(
    filled_database_with_view: Database, ) -> None:
    keys = [
        doc.id
        async for doc in filled_database_with_view.docs(include_ddocs=True)
    ]

    assert "_design/test_ddoc" in keys
示例#4
0
async def test_many_docs(large_filled_database: Database) -> None:
    keys = [key async for key in large_filled_database.akeys()]
    assert len(keys) == 2000

    docs = [doc async for doc in large_filled_database.docs()]
    assert len(docs) == 2000

    find_docs = [
        doc async for doc in large_filled_database.find(
            selector={"llama": "awesome"})
    ]
    assert len(find_docs) == 2000
示例#5
0
async def test_docs_do_not_contain_ddocs(
        filled_database_with_view: Database) -> None:
    keys = [doc.id async for doc in filled_database_with_view.docs()]

    assert "_design/test_ddoc" not in keys
示例#6
0
async def test_docs_with_no_ids(filled_database: Database) -> None:
    keys = [doc.id async for doc in filled_database.docs()]

    assert len(keys) == 4
    assert sorted(keys) == ["baz", "baz2", "foo", "foo2"]
示例#7
0
async def test_docs_with_prefix(filled_database: Database) -> None:
    keys = [doc.id async for doc in filled_database.docs(prefix="ba")]

    assert len(keys) == 2
    assert (sorted(keys)) == ["baz", "baz2"]
示例#8
0
async def test_docs_filtered(filled_database: Database) -> None:
    keys = [doc.id async for doc in filled_database.docs(["foo", "baz"])]

    assert len(keys) == 2
    assert "foo" in keys
    assert "baz" in keys
示例#9
0
async def test_docs_on_empty(database: Database) -> None:
    all_docs = [doc async for doc in database.docs([])]

    assert all_docs == []