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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"""

Expand Down
4 changes: 2 additions & 2 deletions arangoasync/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3004,15 +3004,15 @@ async def metrics(self, server_id: Optional[str] = None) -> Result[str]:
ServerMetricsError: If the operation fails.

References:
- `metrics-api-v2 <https://docs.arango.ai/arangodb/stable/develop/http-api/monitoring/metrics/#metrics-api-v2>`__
- `metrics-api <https://docs.arango.ai/arangodb/stable/develop/http-api/monitoring/metrics/#metrics-api>`__
""" # noqa: E501
params: Params = {}
if server_id is not None:
params["serverId"] = server_id

request = Request(
method=Method.GET,
endpoint="/_admin/metrics/v2",
endpoint="/_admin/metrics",
params=params,
)

Expand Down
2 changes: 1 addition & 1 deletion docs/graph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"""

Expand Down
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"""

Expand Down
23 changes: 12 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
5 changes: 4 additions & 1 deletion tests/test_aql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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; }"
Expand Down
10 changes: 6 additions & 4 deletions tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
30 changes: 16 additions & 14 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion tests/test_foxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import aiofiles
import aiohttp
import pytest
from packaging import version

from arangoasync.exceptions import (
FoxxCommitError,
Expand Down Expand Up @@ -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")

Expand Down
6 changes: 5 additions & 1 deletion tests/test_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from packaging import version

from arangoasync.exceptions import (
TaskCreateError,
Expand All @@ -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")

Expand Down
Loading