From 1cc49085a5f60c6c6f247726e3c3284f8f8e6c08 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sun, 1 Jun 2025 11:52:00 +0000 Subject: [PATCH 1/3] Updated API --- arango/collection.py | 111 ++++++++------------------- arango/exceptions.py | 4 + arango/graph.py | 179 ++++++++++++++++++++++++------------------- tests/test_graph.py | 20 ++--- 4 files changed, 146 insertions(+), 168 deletions(-) diff --git a/arango/collection.py b/arango/collection.py index a996dc5c..a48bfd2a 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -3008,9 +3008,8 @@ def insert( self, vertex: Json, sync: Optional[bool] = None, - silent: bool = False, return_new: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Insert a new vertex document. :param vertex: New vertex document to insert. If it has "_key" or "_id" @@ -3019,20 +3018,16 @@ def insert( :type vertex: dict :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool :param return_new: Include body of the new document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_new: bool - :return: Document metadata (e.g. document key, revision), or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentInsertError: If insert fails. """ vertex = self._ensure_key_from_id(vertex) - params: Params = {"silent": silent, "returnNew": return_new} + params: Params = {"returnNew": return_new} if sync is not None: params["waitForSync"] = sync @@ -3044,11 +3039,9 @@ def insert( write=self.name, ) - def response_handler(resp: Response) -> Union[bool, Json]: + def response_handler(resp: Response) -> Json: if not resp.is_success: raise DocumentInsertError(resp, request) - if silent: - return True return format_vertex(resp.body) return self._execute(request, response_handler) @@ -3059,10 +3052,9 @@ def update( check_rev: bool = True, keep_none: bool = True, sync: Optional[bool] = None, - silent: bool = False, return_old: bool = False, return_new: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Update a vertex document. :param vertex: Partial or full vertex document with updated values. It @@ -3076,18 +3068,14 @@ def update( :type keep_none: bool | None :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool :param return_old: Include body of the old document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_old: bool :param return_new: Include body of the new document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_new: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentUpdateError: If update fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ @@ -3096,7 +3084,6 @@ def update( params: Params = { "keepNull": keep_none, "overwrite": not check_rev, - "silent": silent, "returnNew": return_new, "returnOld": return_old, } @@ -3112,13 +3099,11 @@ def update( write=self.name, ) - def response_handler(resp: Response) -> Union[bool, Json]: + def response_handler(resp: Response) -> Json: if resp.status_code == 412: # pragma: no cover raise DocumentRevisionError(resp, request) elif not resp.is_success: raise DocumentUpdateError(resp, request) - if silent is True: - return True return format_vertex(resp.body) return self._execute(request, response_handler) @@ -3128,10 +3113,9 @@ def replace( vertex: Json, check_rev: bool = True, sync: Optional[bool] = None, - silent: bool = False, return_old: bool = False, return_new: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Replace a vertex document. :param vertex: New vertex document to replace the old one with. It must @@ -3142,25 +3126,20 @@ def replace( :type check_rev: bool :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool :param return_old: Include body of the old document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_old: bool :param return_new: Include body of the new document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_new: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentReplaceError: If replace fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ vertex_id, headers = self._prep_from_body(vertex, check_rev) params: Params = { - "silent": silent, "returnNew": return_new, "returnOld": return_old, } @@ -3176,13 +3155,11 @@ def replace( write=self.name, ) - def response_handler(resp: Response) -> Union[bool, Json]: + def response_handler(resp: Response) -> Json: if resp.status_code == 412: # pragma: no cover raise DocumentRevisionError(resp, request) elif not resp.is_success: raise DocumentReplaceError(resp, request) - if silent is True: - return True return format_vertex(resp.body) return self._execute(request, response_handler) @@ -3326,9 +3303,8 @@ def insert( self, edge: Json, sync: Optional[bool] = None, - silent: bool = False, return_new: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Insert a new edge document. :param edge: New edge document to insert. It must contain "_from" and @@ -3338,20 +3314,16 @@ def insert( :type edge: dict :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool :param return_new: Include body of the new document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_new: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentInsertError: If insert fails. """ edge = self._ensure_key_from_id(edge) - params: Params = {"silent": silent, "returnNew": return_new} + params: Params = {"returnNew": return_new} if sync is not None: params["waitForSync"] = sync @@ -3363,11 +3335,9 @@ def insert( write=self.name, ) - def response_handler(resp: Response) -> Union[bool, Json]: + def response_handler(resp: Response) -> Json: if not resp.is_success: raise DocumentInsertError(resp, request) - if silent: - return True return format_edge(resp.body) return self._execute(request, response_handler) @@ -3378,10 +3348,9 @@ def update( check_rev: bool = True, keep_none: bool = True, sync: Optional[bool] = None, - silent: bool = False, return_old: bool = False, return_new: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Update an edge document. :param edge: Partial or full edge document with updated values. It must @@ -3395,18 +3364,14 @@ def update( :type keep_none: bool | None :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool :param return_old: Include body of the old document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_old: bool :param return_new: Include body of the new document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_new: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentUpdateError: If update fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ @@ -3415,7 +3380,6 @@ def update( params: Params = { "keepNull": keep_none, "overwrite": not check_rev, - "silent": silent, "returnNew": return_new, "returnOld": return_old, } @@ -3431,13 +3395,11 @@ def update( write=self.name, ) - def response_handler(resp: Response) -> Union[bool, Json]: + def response_handler(resp: Response) -> Json: if resp.status_code == 412: # pragma: no cover raise DocumentRevisionError(resp, request) if not resp.is_success: raise DocumentUpdateError(resp, request) - if silent is True: - return True return format_edge(resp.body) return self._execute(request, response_handler) @@ -3447,10 +3409,9 @@ def replace( edge: Json, check_rev: bool = True, sync: Optional[bool] = None, - silent: bool = False, return_old: bool = False, return_new: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Replace an edge document. :param edge: New edge document to replace the old one with. It must @@ -3462,25 +3423,20 @@ def replace( :type check_rev: bool :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool :param return_old: Include body of the old document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_old: bool :param return_new: Include body of the new document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_new: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentReplaceError: If replace fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ edge_id, headers = self._prep_from_body(edge, check_rev) params: Params = { - "silent": silent, "returnNew": return_new, "returnOld": return_old, } @@ -3496,13 +3452,11 @@ def replace( write=self.name, ) - def response_handler(resp: Response) -> Union[bool, Json]: + def response_handler(resp: Response) -> Json: if resp.status_code == 412: # pragma: no cover raise DocumentRevisionError(resp, request) if not resp.is_success: raise DocumentReplaceError(resp, request) - if silent is True: - return True return format_edge(resp.body) return self._execute(request, response_handler) @@ -3575,9 +3529,8 @@ def link( to_vertex: Union[str, Json], data: Optional[Json] = None, sync: Optional[bool] = None, - silent: bool = False, return_new: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Insert a new edge document linking the given vertices. :param from_vertex: "From" vertex document ID or body with "_id" field. @@ -3590,21 +3543,17 @@ def link( :type data: dict | None :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool :param return_new: Include body of the new document in the returned metadata. Ignored if parameter **silent** is set to True. :type return_new: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentInsertError: If insert fails. """ edge = {"_from": get_doc_id(from_vertex), "_to": get_doc_id(to_vertex)} if data is not None: edge.update(self._ensure_key_from_id(data)) - return self.insert(edge, sync=sync, silent=silent, return_new=return_new) + return self.insert(edge, sync=sync, return_new=return_new) def edges( self, diff --git a/arango/exceptions.py b/arango/exceptions.py index 29bcdc17..cdea90c5 100644 --- a/arango/exceptions.py +++ b/arango/exceptions.py @@ -543,6 +543,10 @@ class VertexCollectionDeleteError(ArangoServerError): """Failed to delete vertex collection.""" +class EdgeCollectionListError(ArangoServerError): + """Failed to retrieve edge collections.""" + + class EdgeDefinitionListError(ArangoServerError): """Failed to retrieve edge definitions.""" diff --git a/arango/graph.py b/arango/graph.py index 3279129f..589e9c44 100644 --- a/arango/graph.py +++ b/arango/graph.py @@ -7,6 +7,7 @@ from arango.collection import EdgeCollection, VertexCollection from arango.connection import Connection from arango.exceptions import ( + EdgeCollectionListError, EdgeDefinitionCreateError, EdgeDefinitionDeleteError, EdgeDefinitionListError, @@ -136,19 +137,28 @@ def vertex_collection(self, name: str) -> VertexCollection: """ return VertexCollection(self._conn, self._executor, self._name, name) - def create_vertex_collection(self, name: str) -> Result[VertexCollection]: + def create_vertex_collection( + self, + name: str, + options: Optional[Json] = None, + ) -> Result[VertexCollection]: """Create a vertex collection in the graph. :param name: Vertex collection name. :type name: str + :param options: Additional options for creating vertex collections. + :type options: dict | None :return: Vertex collection API wrapper. :rtype: arango.collection.VertexCollection :raise arango.exceptions.VertexCollectionCreateError: If create fails. """ + data: Json = {"collection": name} + if options is not None: + data["options"] = options request = Request( method="post", endpoint=f"/_api/gharial/{self._name}/vertex", - data={"collection": name}, + data=data, ) def response_handler(resp: Response) -> VertexCollection: @@ -259,6 +269,7 @@ def create_edge_definition( edge_collection: str, from_vertex_collections: Sequence[str], to_vertex_collections: Sequence[str], + options: Optional[Json] = None, ) -> Result[EdgeCollection]: """Create a new edge definition. @@ -279,18 +290,24 @@ def create_edge_definition( :type from_vertex_collections: [str] :param to_vertex_collections: Names of "to" vertex collections. :type to_vertex_collections: [str] + :param options: Additional options for creating edge definitions. + :type options: dict | None :return: Edge collection API wrapper. :rtype: arango.collection.EdgeCollection :raise arango.exceptions.EdgeDefinitionCreateError: If create fails. """ + data: Json = { + "collection": edge_collection, + "from": from_vertex_collections, + "to": to_vertex_collections, + } + if options is not None: + data["options"] = options + request = Request( method="post", endpoint=f"/_api/gharial/{self._name}/edge", - data={ - "collection": edge_collection, - "from": from_vertex_collections, - "to": to_vertex_collections, - }, + data=data, ) def response_handler(resp: Response) -> EdgeCollection: @@ -300,11 +317,32 @@ def response_handler(resp: Response) -> EdgeCollection: return self._execute(request, response_handler) + def edge_collections(self) -> Result[List[str]]: + """Get the names of all edge collections in the graph. + + :return: Edge collections in the graph. + :rtype: list + :raise: arango.exceptions.EdgeCollectionListError: If retrieval fails. + """ + request = Request( + method="get", + endpoint=f"/_api/gharial/{self._name}/edge", + ) + + def response_handler(resp: Response) -> List[str]: + if not resp.is_success: + raise EdgeCollectionListError(resp, request) + return list(sorted(resp.body["collections"])) + + return self._execute(request, response_handler) + def replace_edge_definition( self, edge_collection: str, from_vertex_collections: Sequence[str], to_vertex_collections: Sequence[str], + sync: Optional[bool] = None, + purge: bool = False, ) -> Result[EdgeCollection]: """Replace an edge definition. @@ -314,18 +352,28 @@ def replace_edge_definition( :type from_vertex_collections: [str] :param to_vertex_collections: Names of "to" vertex collections. :type to_vertex_collections: [str] + :param sync: Block until operation is synchronized to disk. + :type sync: bool | None + :param purge: Drop the edge collection in addition to removing it from + the graph. The collection is only dropped if it is not used in other graphs. + :type purge: bool :return: Edge collection API wrapper. :rtype: arango.collection.EdgeCollection :raise arango.exceptions.EdgeDefinitionReplaceError: If replace fails. """ + data: Json = { + "collection": edge_collection, + "from": from_vertex_collections, + "to": to_vertex_collections, + "purge": purge, + } + if sync is not None: + data["waitForSync"] = sync + request = Request( method="put", endpoint=f"/_api/gharial/{self._name}/edge/{edge_collection}", - data={ - "collection": edge_collection, - "from": from_vertex_collections, - "to": to_vertex_collections, - }, + data=data, ) def response_handler(resp: Response) -> EdgeCollection: @@ -335,7 +383,12 @@ def response_handler(resp: Response) -> EdgeCollection: return self._execute(request, response_handler) - def delete_edge_definition(self, name: str, purge: bool = False) -> Result[bool]: + def delete_edge_definition( + self, + name: str, + purge: bool = False, + sync: Optional[bool] = None, + ) -> Result[bool]: """Delete an edge definition from the graph. :param name: Edge collection name. @@ -344,14 +397,20 @@ def delete_edge_definition(self, name: str, purge: bool = False) -> Result[bool] from the graph but the edge collection is also deleted completely from the database. :type purge: bool + :sync: Block until operation is synchronized to disk. + :type sync: bool | None :return: True if edge definition was deleted successfully. :rtype: bool :raise arango.exceptions.EdgeDefinitionDeleteError: If delete fails. """ + params: Json = {"dropCollections": purge} + if sync is not None: + params["waitForSync"] = sync + request = Request( method="delete", endpoint=f"/_api/gharial/{self._name}/edge/{name}", - params={"dropCollections": purge}, + params=params, ) def response_handler(resp: Response) -> bool: @@ -549,8 +608,7 @@ def insert_vertex( collection: str, vertex: Json, sync: Optional[bool] = None, - silent: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Insert a new vertex document. :param collection: Vertex collection name. @@ -561,15 +619,11 @@ def insert_vertex( :type vertex: dict :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentInsertError: If insert fails. """ - return self.vertex_collection(collection).insert(vertex, sync, silent) + return self.vertex_collection(collection).insert(vertex, sync) def update_vertex( self, @@ -577,8 +631,7 @@ def update_vertex( check_rev: bool = True, keep_none: bool = True, sync: Optional[bool] = None, - silent: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Update a vertex document. :param vertex: Partial or full vertex document with updated values. It @@ -592,12 +645,8 @@ def update_vertex( :type keep_none: bool :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentUpdateError: If update fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ @@ -606,7 +655,6 @@ def update_vertex( check_rev=check_rev, keep_none=keep_none, sync=sync, - silent=silent, ) def replace_vertex( @@ -614,8 +662,7 @@ def replace_vertex( vertex: Json, check_rev: bool = True, sync: Optional[bool] = None, - silent: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Replace a vertex document. :param vertex: New vertex document to replace the old one with. It must @@ -626,17 +673,15 @@ def replace_vertex( :type check_rev: bool :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentReplaceError: If replace fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ return self._get_col_by_vertex(vertex).replace( - vertex=vertex, check_rev=check_rev, sync=sync, silent=silent + vertex=vertex, + check_rev=check_rev, + sync=sync, ) def delete_vertex( @@ -727,8 +772,7 @@ def insert_edge( collection: str, edge: Json, sync: Optional[bool] = None, - silent: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Insert a new edge document. :param collection: Edge collection name. @@ -740,15 +784,11 @@ def insert_edge( :type edge: dict :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentInsertError: If insert fails. """ - return self.edge_collection(collection).insert(edge, sync, silent) + return self.edge_collection(collection).insert(edge, sync) def update_edge( self, @@ -756,8 +796,7 @@ def update_edge( check_rev: bool = True, keep_none: bool = True, sync: Optional[bool] = None, - silent: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Update an edge document. :param edge: Partial or full edge document with updated values. It must @@ -771,12 +810,8 @@ def update_edge( :type keep_none: bool | None :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentUpdateError: If update fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ @@ -785,7 +820,6 @@ def update_edge( check_rev=check_rev, keep_none=keep_none, sync=sync, - silent=silent, ) def replace_edge( @@ -793,8 +827,7 @@ def replace_edge( edge: Json, check_rev: bool = True, sync: Optional[bool] = None, - silent: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Replace an edge document. :param edge: New edge document to replace the old one with. It must @@ -806,17 +839,15 @@ def replace_edge( :type check_rev: bool :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentReplaceError: If replace fails. :raise arango.exceptions.DocumentRevisionError: If revisions mismatch. """ return self._get_col_by_edge(edge).replace( - edge=edge, check_rev=check_rev, sync=sync, silent=silent + edge=edge, + check_rev=check_rev, + sync=sync, ) def delete_edge( @@ -865,8 +896,7 @@ def link( to_vertex: Union[str, Json], data: Optional[Json] = None, sync: Optional[bool] = None, - silent: bool = False, - ) -> Result[Union[bool, Json]]: + ) -> Result[Json]: """Insert a new edge document linking the given vertices. :param collection: Edge collection name. @@ -881,12 +911,8 @@ def link( :type data: dict :param sync: Block until operation is synchronized to disk. :type sync: bool | None - :param silent: If set to True, no document metadata is returned. This - can be used to save resources. - :type silent: bool - :return: Document metadata (e.g. document key, revision) or True if - parameter **silent** was set to True. - :rtype: bool | dict + :return: Document metadata (e.g. document key, revision). + :rtype: dict :raise arango.exceptions.DocumentInsertError: If insert fails. """ return self.edge_collection(collection).link( @@ -894,7 +920,6 @@ def link( to_vertex=to_vertex, data=data, sync=sync, - silent=silent, ) def edges( diff --git a/tests/test_graph.py b/tests/test_graph.py index fe63455d..fd3242fe 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -334,6 +334,7 @@ def test_create_graph_with_edge_definition(db): ) assert edge_definition in new_graph.edge_definitions() assert ovcol_name in new_graph.vertex_collections() + assert edge_definition["edge_collection"] in new_graph.edge_collections() def test_vertex_management(fvcol, bad_fvcol, fvdocs): @@ -394,7 +395,7 @@ def test_vertex_management(fvcol, bad_fvcol, fvdocs): key = vertex["_key"] # Test insert third valid vertex with silent set to True - assert fvcol.insert(vertex, silent=True) is True + assert isinstance(fvcol.insert(vertex), dict) assert len(fvcol) == 3 assert fvcol[key]["val"] == vertex["val"] @@ -444,7 +445,7 @@ def test_vertex_management(fvcol, bad_fvcol, fvdocs): # Test update vertex with silent set to True assert "bar" not in fvcol[vertex] - assert fvcol.update({"_key": key, "bar": 200}, silent=True) is True + assert isinstance(fvcol.update({"_key": key, "bar": 200}), dict) assert fvcol[vertex]["bar"] == 200 assert fvcol[vertex]["_rev"] != old_rev old_rev = fvcol[key]["_rev"] @@ -519,7 +520,7 @@ def test_vertex_management(fvcol, bad_fvcol, fvdocs): assert "vertex" in result # Test replace vertex with silent set to True - assert fvcol.replace({"_key": key, "bar": 200}, silent=True) is True + assert isinstance(fvcol.replace({"_key": key, "bar": 200}), dict) assert "foo" not in fvcol[key] assert "baz" not in fvcol[vertex] assert fvcol[vertex]["bar"] == 200 @@ -698,7 +699,7 @@ def test_edge_management(ecol, bad_ecol, edocs, fvcol, fvdocs, tvcol, tvdocs): key = edge["_key"] # Test insert second valid edge with silent set to True - assert ecol.insert(edge, sync=True, silent=True) is True + assert isinstance(ecol.insert(edge, sync=True), dict) assert edge in ecol and key in ecol assert len(ecol) == 2 assert ecol[key]["_from"] == edge["_from"] @@ -714,15 +715,14 @@ def test_edge_management(ecol, bad_ecol, edocs, fvcol, fvdocs, tvcol, tvdocs): # Test insert fourth valid edge using link method from_vertex = fvcol.get(fvdocs[2]) to_vertex = tvcol.get(tvdocs[0]) - assert ( + assert isinstance( ecol.link( from_vertex["_id"], to_vertex["_id"], {"_id": ecol.name + "/foo"}, sync=True, - silent=True, - ) - is True + ), + dict, ) assert "foo" in ecol assert len(ecol) == 4 @@ -816,7 +816,7 @@ def test_edge_management(ecol, bad_ecol, edocs, fvcol, fvdocs, tvcol, tvdocs): old_rev = result["_rev"] # Test update edge with silent option - assert ecol.update({"_key": key, "bar": 600}, silent=True) is True + assert isinstance(ecol.update({"_key": key, "bar": 600}), dict) assert ecol[key]["foo"] == 200 assert ecol[key]["bar"] == 600 assert ecol[key]["_rev"] != old_rev @@ -852,7 +852,7 @@ def test_edge_management(ecol, bad_ecol, edocs, fvcol, fvdocs, tvcol, tvdocs): # Test replace edge with silent set to True edge["bar"] = 200 - assert ecol.replace(edge, silent=True) is True + assert isinstance(ecol.replace(edge), dict) assert ecol[key]["foo"] == 100 assert ecol[key]["bar"] == 200 assert ecol[key]["_rev"] != old_rev From 317847d5c465e8917f4e777139e7282b470115a9 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sun, 1 Jun 2025 11:56:02 +0000 Subject: [PATCH 2/3] Bumping up driver version --- arango/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arango/request.py b/arango/request.py index abb2b0db..11ff91c6 100644 --- a/arango/request.py +++ b/arango/request.py @@ -12,7 +12,7 @@ def normalize_headers( if driver_flags is not None: for flag in driver_flags: flags = flags + flag + ";" - driver_version = "8.1.7" + driver_version = "8.2.0" driver_header = "python-arango/" + driver_version + " (" + flags + ")" normalized_headers: Headers = { "charset": "utf-8", From 49b299769701e279ae44ea051726a20c36c2a465 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sun, 1 Jun 2025 12:08:31 +0000 Subject: [PATCH 3/3] Updating docs --- docs/graph.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/graph.rst b/docs/graph.rst index 0b37154f..0645d5b6 100644 --- a/docs/graph.rst +++ b/docs/graph.rst @@ -83,6 +83,7 @@ Here is an example showing how edge definitions are managed: # Create an edge definition named "teach". This creates any missing # collections and returns an API wrapper for "teach" edge collection. + # At first, create a wrong teachers->teachers mapping intentionally. if not school.has_edge_definition('teach'): teach = school.create_edge_definition( edge_collection='teach', @@ -93,7 +94,7 @@ Here is an example showing how edge definitions are managed: # List edge definitions. school.edge_definitions() - # Replace the edge definition. + # Replace with the correct edge definition. school.replace_edge_definition( edge_collection='teach', from_vertex_collections=['teachers'],