示例#1
0
def test_delete_document(test_client):
    filename = "delete_document.xml"
    document = Document("<delete/>", existdb_client=test_client)
    document.existdb_store(filename=filename)
    document.existdb_delete()
    with pytest.raises(FailedDocumentLoading):
        Document(f"existdb://admin:@localhost:8080/exist/db/tests/{filename}")
示例#2
0
def test_store_document(test_client):
    test_client.root_collection = "/db/apps/"
    document = Document(
        "<test/>",
        existdb_client=test_client,
    )
    document.existdb_store(collection="/test_collection/",
                           filename="new_document.xml")

    document = Document(
        "existdb://admin:@localhost:8080/exist/db/apps/test-data/dada_manifest.xml"
    )
    document.existdb_store(replace_existing=True)
    document.existdb_store(
        collection="/another/collection/",
        filename="another_name.xml",
    )
    assert document.existdb_collection == "/db/apps/test-data"
    assert document.existdb_filename == "dada_manifest.xml"

    document.existdb_collection = "/another/collection/"
    document.existdb_filename = "another_name.xml"
    with pytest.raises(SnakesistWriteError):
        document.existdb_store()

    test_client.root_collection = "/"
    document.existdb_collection = collection = "/db/apps/test_collection/"
    document.existdb_filename = filename = "new_document.xml"
    document.existdb_store(replace_existing=True)
    assert (Document(f"{collection}{filename}",
                     existdb_client=test_client).root.local_name != "test")