From 6206f3d6ebbe4201fbb8efc952dd9e4752dc00be Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 1 Aug 2022 17:50:21 +0400 Subject: [PATCH 1/7] commit --- arango/collection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arango/collection.py b/arango/collection.py index aac97bb9..078a2352 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -2,6 +2,7 @@ from numbers import Number from typing import List, Optional, Sequence, Tuple, Union +import warnings from arango.api import ApiGroup from arango.connection import Connection @@ -659,6 +660,13 @@ def export( :rtype: arango.cursor.Cursor :raise arango.exceptions.DocumentGetError: If export fails. """ + + deprec_msg = """ + This method is obsolete and will be removed in the next version. + Create a cursor for your query. + """ + warnings.warn(message=deprec_msg, category=DeprecationWarning) + data: Json = {"count": count, "flush": flush} if flush_wait is not None: data["flushWait"] = flush_wait From eadde366c7e402adfbdf45b0f4e8a597b15dbe65 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 1 Aug 2022 19:22:59 +0400 Subject: [PATCH 2/7] Removed collection.export method --- arango/collection.py | 68 -------------------------------------------- 1 file changed, 68 deletions(-) diff --git a/arango/collection.py b/arango/collection.py index 078a2352..ce7e0040 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -624,74 +624,6 @@ def response_handler(resp: Response) -> Cursor: return self._execute(request, response_handler) - def export( - self, - limit: Optional[int] = None, - count: bool = False, - batch_size: Optional[int] = None, - flush: bool = False, - flush_wait: Optional[int] = None, - ttl: Optional[Number] = None, - filter_fields: Optional[Sequence[str]] = None, - filter_type: str = "include", - ) -> Result[Cursor]: - """Export all documents in the collection using a server cursor. - - :param flush: If set to True, flush the write-ahead log prior to the - export. If set to False, documents in the write-ahead log during - the export are not included in the result. - :type flush: bool - :param flush_wait: Max wait time in seconds for write-ahead log flush. - :type flush_wait: int | None - :param count: Include the document count in the server cursor. - :type count: bool - :param batch_size: Max number of documents in the batch fetched by - the cursor in one round trip. - :type batch_size: int | None - :param limit: Max number of documents fetched by the cursor. - :type limit: int | None - :param ttl: Time-to-live for the cursor on the server. - :type ttl: int | float | None - :param filter_fields: Document fields to filter with. - :type filter_fields: [str] | None - :param filter_type: Allowed values are "include" or "exclude". - :type filter_type: str - :return: Document cursor. - :rtype: arango.cursor.Cursor - :raise arango.exceptions.DocumentGetError: If export fails. - """ - - deprec_msg = """ - This method is obsolete and will be removed in the next version. - Create a cursor for your query. - """ - warnings.warn(message=deprec_msg, category=DeprecationWarning) - - data: Json = {"count": count, "flush": flush} - if flush_wait is not None: - data["flushWait"] = flush_wait - if batch_size is not None: - data["batchSize"] = batch_size - if limit is not None: - data["limit"] = limit - if ttl is not None: - data["ttl"] = ttl - if filter_fields is not None: - data["restrict"] = {"fields": filter_fields, "type": filter_type} - request = Request( - method="post", - endpoint="/_api/export", - params={"collection": self.name}, - data=data, - ) - - def response_handler(resp: Response) -> Cursor: - if not resp.is_success: - raise DocumentGetError(resp, request) - return Cursor(self._conn, resp.body, "export") - - return self._execute(request, response_handler) - def find( self, filters: Json, skip: Optional[int] = None, limit: Optional[int] = None ) -> Result[Cursor]: From e672cbc4c4a827212d9cdd181c02e3678e000249 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 1 Aug 2022 19:27:22 +0400 Subject: [PATCH 3/7] Fixed reference in docs --- docs/simple.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/simple.rst b/docs/simple.rst index acbd2532..4d483e65 100644 --- a/docs/simple.rst +++ b/docs/simple.rst @@ -48,7 +48,6 @@ Here is an example of using ArangoDB's **simply queries**: Here are all simple query (and other utility) methods available: * :func:`arango.collection.Collection.all` -* :func:`arango.collection.Collection.export` * :func:`arango.collection.Collection.find` * :func:`arango.collection.Collection.find_near` * :func:`arango.collection.Collection.find_in_range` From 7bc746a064c77e73162e039943f5cfcfe5b87e03 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 1 Aug 2022 19:30:11 +0400 Subject: [PATCH 4/7] Remove warnings import --- arango/collection.py | 1 - 1 file changed, 1 deletion(-) diff --git a/arango/collection.py b/arango/collection.py index ce7e0040..30eae2d2 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -2,7 +2,6 @@ from numbers import Number from typing import List, Optional, Sequence, Tuple, Union -import warnings from arango.api import ApiGroup from arango.connection import Connection From df8dcbfbde0117f5a6eaf6418c793ee35ea86275 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 1 Aug 2022 19:35:20 +0400 Subject: [PATCH 5/7] Removed collection.export from tests --- tests/test_document.py | 71 ------------------------------------------ 1 file changed, 71 deletions(-) diff --git a/tests/test_document.py b/tests/test_document.py index d7db480a..8aa78bcf 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -1675,77 +1675,6 @@ def test_document_keys(col, bad_col, docs): bad_col.keys() assert err.value.error_code in {11, 1228} - -def test_document_export(col, bad_col, docs, cluster): - if cluster: - pytest.skip("Not tested in a cluster setup") - - # Set up test documents - col.insert_many(docs) - - # Test export with flush set to True and flush_wait set to 1 - cursor = col.export(flush=True, flush_wait=1) - assert clean_doc(cursor) == docs - assert cursor.type == "export" - - # Test export with count - cursor = col.export(flush=False, count=True) - assert cursor.count() == len(docs) - assert clean_doc(cursor) == docs - - # Test export with batch size - cursor = col.export(flush=False, count=True, batch_size=1) - assert cursor.count() == len(docs) - assert clean_doc(cursor) == docs - - # Test export with time-to-live - cursor = col.export(flush=False, count=True, ttl=10) - assert cursor.count() == len(docs) - assert clean_doc(cursor) == docs - - # Test export with filters - cursor = col.export( - count=True, flush=False, filter_fields=["text"], filter_type="exclude" - ) - assert cursor.count() == len(docs) - assert all(["text" not in d for d in cursor]) - - # Test export with a limit of 0 - cursor = col.export(flush=False, count=True, limit=0) - assert cursor.count() == 0 - assert clean_doc(cursor) == [] - - # Test export with a limit of 1 - cursor = col.export(flush=False, count=True, limit=1) - assert cursor.count() == 1 - assert len(list(cursor)) == 1 - all([clean_doc(d) in docs for d in cursor]) - - # Test export with a limit of 3 - cursor = col.export(flush=False, count=True, limit=3) - assert cursor.count() == 3 - assert len(list(cursor)) == 3 - all([clean_doc(d) in docs for d in cursor]) - - # Test export with bad database - with assert_raises(DocumentGetError): - bad_col.export() - - # Test closing export cursor - cursor = col.export(flush=False, count=True, batch_size=1) - assert cursor.close(ignore_missing=False) is True - assert cursor.close(ignore_missing=True) is False - - assert clean_doc(cursor.next()) in docs - with assert_raises(CursorNextError): - cursor.next() - with assert_raises(CursorCloseError): - cursor.close(ignore_missing=False) - - cursor = col.export(flush=False, count=True) - assert cursor.close(ignore_missing=True) is None - - def test_document_random(col, bad_col, docs): # Set up test documents col.import_bulk(docs) From 26705cc7fcb2a0c9f299b08adaa85c5690453d2a Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 1 Aug 2022 19:41:20 +0400 Subject: [PATCH 6/7] Reformatted tests\test_document.py --- tests/test_document.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_document.py b/tests/test_document.py index 8aa78bcf..0b2608e5 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -1675,6 +1675,7 @@ def test_document_keys(col, bad_col, docs): bad_col.keys() assert err.value.error_code in {11, 1228} + def test_document_random(col, bad_col, docs): # Set up test documents col.import_bulk(docs) From 1d4bbb817bee73e292ae0d4ca10cd4e08f627d5f Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 1 Aug 2022 19:44:04 +0400 Subject: [PATCH 7/7] Removed unused Exception references --- tests/test_document.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_document.py b/tests/test_document.py index 0b2608e5..9c5ce6bd 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -1,8 +1,6 @@ import pytest from arango.exceptions import ( - CursorCloseError, - CursorNextError, DocumentCountError, DocumentDeleteError, DocumentGetError,