Skip to content

Commit 128d328

Browse files
committed
Using randomized graph name
1 parent 9dc1353 commit 128d328

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

tests/helpers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ def generate_col_name():
1919
return f"test_collection_{uuid4().hex}"
2020

2121

22+
def generate_graph_name():
23+
"""Generate and return a random graph name.
24+
25+
Returns:
26+
str: Random graph name.
27+
"""
28+
return f"test_graph_{uuid4().hex}"
29+
30+
2231
def generate_username():
2332
"""Generate and return a random username.
2433

tests/test_graph.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,50 @@
11
import pytest
22

33
from arangoasync.exceptions import GraphCreateError, GraphDeleteError, GraphListError
4+
from tests.helpers import generate_graph_name
45

56

67
@pytest.mark.asyncio
78
async def test_graph_basic(db, bad_db):
9+
graph1_name = generate_graph_name()
810
# Test the graph representation
9-
graph = db.graph("test_graph")
10-
assert graph.name == "test_graph"
11-
assert "test_graph" in repr(graph)
11+
graph = db.graph(graph1_name)
12+
assert graph.name == graph1_name
13+
assert graph1_name in repr(graph)
1214

1315
# Cannot find any graph
16+
graph2_name = generate_graph_name()
1417
assert await db.graphs() == []
15-
assert await db.has_graph("fake_graph") is False
18+
assert await db.has_graph(graph2_name) is False
1619
with pytest.raises(GraphListError):
17-
await bad_db.has_graph("fake_graph")
20+
await bad_db.has_graph(graph2_name)
1821
with pytest.raises(GraphListError):
1922
await bad_db.graphs()
2023

2124
# Create a graph
22-
graph = await db.create_graph("test_graph", wait_for_sync=True)
23-
assert graph.name == "test_graph"
25+
graph = await db.create_graph(graph1_name, wait_for_sync=True)
26+
assert graph.name == graph1_name
2427
with pytest.raises(GraphCreateError):
25-
await bad_db.create_graph("test_graph")
28+
await bad_db.create_graph(graph1_name)
2629

2730
# Check if the graph exists
28-
assert await db.has_graph("test_graph") is True
31+
assert await db.has_graph(graph1_name) is True
2932
graphs = await db.graphs()
3033
assert len(graphs) == 1
31-
assert graphs[0].name == "test_graph"
34+
assert graphs[0].name == graph1_name
3235

3336
# Delete the graph
34-
await db.delete_graph("test_graph")
35-
assert await db.has_graph("test_graph") is False
37+
await db.delete_graph(graph1_name)
38+
assert await db.has_graph(graph1_name) is False
3639
with pytest.raises(GraphDeleteError):
37-
await bad_db.delete_graph("test_graph")
40+
await bad_db.delete_graph(graph1_name)
41+
42+
43+
async def test_graph_properties(db):
44+
# Create a graph
45+
name = generate_graph_name()
46+
graph = await db.create_graph(name)
47+
48+
# Get the properties of the graph
49+
properties = await graph.properties()
50+
assert properties.name == name

0 commit comments

Comments
 (0)