Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test-app/src/main/ml-data/collections.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*=test-data
3 changes: 3 additions & 0 deletions test-app/src/main/ml-data/doc1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "world"
}
1 change: 1 addition & 0 deletions test-app/src/main/ml-data/doc2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<hello>world</hello>
1 change: 1 addition & 0 deletions test-app/src/main/ml-data/permissions.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*=rest-reader,read,rest-writer,update
46 changes: 46 additions & 0 deletions tests/test_get_documents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from requests_toolbelt.multipart.decoder import MultipartDecoder


def test_get_docs(test_session):
"""
Possible future client interface:
array_of_documents = client.documents.get(uri=[], metadata=True)

Where each Document in the array would have fields of:
uri/content/collections/permissions/quality/properties/metadata_values.
"""
response = test_session.get(
"http://localhost:8030/v1/documents",
params={
"uri": ["/doc1.json", "/doc2.xml"],
"category": ["content", "metadata"],
"format": "json", # Applies only to metadata
},
headers={"Accept": "multipart/mixed"},
)

# Could provide a class for converting a multipart/mixed response into an array
# of documents too:
# from marklogic import DocumentDecoder
# array_of_documents = DocumentDecoder.from_response(response)

decoder = MultipartDecoder.from_response(response)
for part in decoder.parts:
print(part.headers)
print(part.text)


def test_search_docs(test_session):
response = test_session.get(
"http://localhost:8030/v1/search",
params={
"collection": "test-data",
"category": ["content", "metadata"],
"format": "json", # Applies only to metadata
},
headers={"Accept": "multipart/mixed"}, # Indicates we want documents back.
)

for part in MultipartDecoder.from_response(response).parts:
print(part.headers)
print(part.text)