def test_comments_with_params(server): """Test GET parameters that allow to retrieve partial list of comments.""" if version_lt(server.client.server_version, "10.3"): pytest.skip("Nuxeo 10.3 minimum") doc = Document(name=WORKSPACE_NAME, type="File", properties={"dc:title": "bar.txt"}) doc = server.documents.create(doc, parent_path=WORKSPACE_ROOT) try: # Create a bunch of comments for that document for idx in range(8): doc.comment(f"This is my comment n° {idx}") # Get maximum comments with default values comments = doc.comments() assert len(comments) == 8 # Page 1 comments = doc.comments(pageSize=5, currentPageIndex=0) assert len(comments) == 5 # Page 2 comments = doc.comments(pageSize=5, currentPageIndex=1) assert len(comments) == 3 # Page 3 comments = doc.comments(pageSize=5, currentPageIndex=2) assert len(comments) == 0 finally: doc.delete()
def test_document_comment(server): """Test the Document.comment() method, it is a simple helper.""" if version_lt(server.client.server_version, "10.3"): pytest.skip("Nuxeo 10.3 minimum") doc = Document(name=WORKSPACE_NAME, type="File", properties={"dc:title": "bar.txt"}) doc = server.documents.create(doc, parent_path=WORKSPACE_ROOT) try: # At first, the document has no comment assert not doc.comments() # Create a comment for that document doc.comment("This is my super comment") # There is now 1 comment comments = doc.comments() assert len(comments) == 1 assert comments[0].text == "This is my super comment" # Delete the comment server.comments.delete(comments[0].uid) finally: doc.delete()