diff --git a/README.md b/README.md index e35c413..8fc7aa8 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ async def main(): # Traverse the graph in outbound direction, breath-first. query = """ FOR v, e, p IN 1..3 OUTBOUND 'students/01' GRAPH 'school' - OPTIONS { bfs: true, uniqueVertices: 'global' } + OPTIONS { order: 'bfs', uniqueVertices: 'global' } RETURN {vertex: v, edge: e, path: p} """ diff --git a/arangoasync/database.py b/arangoasync/database.py index 386c036..c00a584 100644 --- a/arangoasync/database.py +++ b/arangoasync/database.py @@ -3004,7 +3004,7 @@ async def metrics(self, server_id: Optional[str] = None) -> Result[str]: ServerMetricsError: If the operation fails. References: - - `metrics-api-v2 `__ + - `metrics-api `__ """ # noqa: E501 params: Params = {} if server_id is not None: @@ -3012,7 +3012,7 @@ async def metrics(self, server_id: Optional[str] = None) -> Result[str]: request = Request( method=Method.GET, - endpoint="/_admin/metrics/v2", + endpoint="/_admin/metrics", params=params, ) diff --git a/docs/graph.rst b/docs/graph.rst index b2c2467..a1adb6a 100644 --- a/docs/graph.rst +++ b/docs/graph.rst @@ -405,7 +405,7 @@ over edges and vertices using various algorithms. # Traverse 1 to 3 hops from the vertex "teachers/jon", query = """ FOR v, e, p IN 1..3 OUTBOUND 'teachers/jon' GRAPH 'school' - OPTIONS { bfs: true, uniqueVertices: 'global' } + OPTIONS { order: 'bfs', uniqueVertices: 'global' } RETURN {vertex: v, edge: e, path: p} """ diff --git a/docs/overview.rst b/docs/overview.rst index 38ecfd7..7b6b3bb 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -116,7 +116,7 @@ Another example with `graphs`_: # Traverse the graph in outbound direction, breath-first. query = """ FOR v, e, p IN 1..3 OUTBOUND 'students/01' GRAPH 'school' - OPTIONS { bfs: true, uniqueVertices: 'global' } + OPTIONS { order: 'bfs', uniqueVertices: 'global' } RETURN {vertex: v, edge: e, path: p} """ diff --git a/tests/conftest.py b/tests/conftest.py index 5025142..e935a10 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -294,18 +294,19 @@ async def teardown(): verify=False, ) - # Remove all tasks - test_tasks = [ - task - for task in await sys_db.tasks() - if task["name"].startswith("test_task") - ] - await asyncio.gather( - *( - sys_db.delete_task(task["id"], ignore_missing=True) - for task in test_tasks + if global_data.db_version < version.parse("4.0.0"): + # Remove all tasks + test_tasks = [ + task + for task in await sys_db.tasks() + if task["name"].startswith("test_task") + ] + await asyncio.gather( + *( + sys_db.delete_task(task["id"], ignore_missing=True) + for task in test_tasks + ) ) - ) # Remove all test users. tst_users = [ diff --git a/tests/test_aql.py b/tests/test_aql.py index 43f3e34..e1c20f3 100644 --- a/tests/test_aql.py +++ b/tests/test_aql.py @@ -304,7 +304,10 @@ async def test_cache_plan_management(db, bad_db, doc_col, docs, db_version): @pytest.mark.asyncio -async def test_aql_function_management(db, bad_db): +async def test_aql_function_management(db_version, db, bad_db): + if db_version >= version.parse("4.0.0"): + pytest.skip("Javascript is not available in ArangoDB v4.0") + fn_group = "functions::temperature" fn_name_1 = "functions::temperature::celsius_to_fahrenheit" fn_body_1 = "function (celsius) { return celsius * 1.8 + 32; }" diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 9a68a6b..63e9e96 100644 --- a/tests/test_cluster.py +++ b/tests/test_cluster.py @@ -60,15 +60,17 @@ async def test_cluster( health = await cluster.health() assert "Health" in health - # DB-Server statistics db_server = None for server in health["Health"]: if server.startswith("PRMR"): db_server = server break - assert db_server is not None, f"No DB server found in {health}" - stats = await cluster.statistics(db_server) - assert "enabled" in stats + + if db_version < version.parse("4.0.0"): + # DB-Server statistics + assert db_server is not None, f"No DB server found in {health}" + stats = await cluster.statistics(db_server) + assert "enabled" in stats # Cluster endpoints endpoints = await cluster.endpoints() diff --git a/tests/test_database.py b/tests/test_database.py index d3df0f2..11ac608 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -90,7 +90,7 @@ async def test_database_misc_methods( # Version v = await sys_db.version() - assert v["version"].startswith("3.") + assert isinstance(v["version"], str) with pytest.raises(ServerVersionError): await bad_db.version() @@ -152,19 +152,20 @@ async def test_database_misc_methods( with pytest.raises(ServerShutdownProgressError): await bad_db.shutdown_progress() - with pytest.raises(ServerReloadRoutingError): - await bad_db.reload_routing() - await sys_db.reload_routing() + if db_version < version.parse("4.0.0"): + with pytest.raises(ServerReloadRoutingError): + await bad_db.reload_routing() + await sys_db.reload_routing() - with pytest.raises(ServerEchoError): - await bad_db.echo() - result = await sys_db.echo() - assert isinstance(result, dict) + with pytest.raises(ServerEchoError): + await bad_db.echo() + result = await sys_db.echo() + assert isinstance(result, dict) - with pytest.raises(ServerExecuteError): - await bad_db.execute("return 1") - result = await sys_db.execute("return 1") - assert result == 1 + with pytest.raises(ServerExecuteError): + await bad_db.execute("return 1") + result = await sys_db.execute("return 1") + assert result == 1 with pytest.raises(DatabaseCompactError): await bad_db.compact() @@ -176,10 +177,11 @@ async def test_database_misc_methods( # Custom Request request = Request( - method=Method.POST, endpoint="/_admin/execute", data="return 1".encode("utf-8") + method=Method.GET, + endpoint="/_api/version", ) response = await sys_db.request(request) - assert json.loads(response.raw_body) == 1 + assert "version" in json.loads(response.raw_body) if "enterprise" not in skip_tests and db_version >= version.parse("3.12.0"): # API calls diff --git a/tests/test_foxx.py b/tests/test_foxx.py index e972dc2..b589611 100644 --- a/tests/test_foxx.py +++ b/tests/test_foxx.py @@ -4,6 +4,7 @@ import aiofiles import aiohttp import pytest +from packaging import version from arangoasync.exceptions import ( FoxxCommitError, @@ -34,7 +35,10 @@ @pytest.mark.asyncio -async def test_foxx(db, bad_db, skip_tests, foxx_path): +async def test_foxx(db_version, db, bad_db, skip_tests, foxx_path): + if db_version >= version.parse("4.0.0"): + pytest.skip("Foxx API has been removed in ArangoDB v4.0") + if "foxx" in skip_tests: pytest.skip("Skipping Foxx tests") diff --git a/tests/test_task.py b/tests/test_task.py index 008e25d..15739d0 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -1,4 +1,5 @@ import pytest +from packaging import version from arangoasync.exceptions import ( TaskCreateError, @@ -10,10 +11,13 @@ @pytest.mark.asyncio -async def test_task_management(sys_db, bad_db, skip_tests): +async def test_task_management(db_version, sys_db, bad_db, skip_tests): # This test intentionally uses the system database because cleaning up tasks is # easier there. + if db_version >= version.parse("4.0.0"): + pytest.skip("The tasks feature is deprecated and removed in ArangoDB v4.0") + if "task" in skip_tests: pytest.skip("Skipping task tests")