3
3
from typing import Generator
4
4
5
5
import pytest
6
+ from pyarrow import ArrowKeyError
6
7
7
8
from graphdatascience import Graph , QueryRunner
8
9
from graphdatascience .arrow_client .authenticated_flight_client import AuthenticatedArrowClient
@@ -29,7 +30,6 @@ def catalog_endpoints(arrow_client: AuthenticatedArrowClient) -> Generator[Catal
29
30
30
31
31
32
def test_list_with_graph (catalog_endpoints : CatalogArrowEndpoints , sample_graph : Graph ) -> None :
32
- """Test listing graphs with a specific graph."""
33
33
results = catalog_endpoints .list (G = sample_graph )
34
34
35
35
assert len (results ) == 1
@@ -46,7 +46,7 @@ def test_list_with_graph(catalog_endpoints: CatalogArrowEndpoints, sample_graph:
46
46
assert "KiB" in result .memory_usage
47
47
assert result .size_in_bytes > 20000
48
48
assert result .modification_time < datetime .datetime .now (datetime .timezone .utc )
49
- assert "p50" in result .degree_distribution
49
+ assert "p50" in result .degree_distribution # type: ignore
50
50
51
51
52
52
def test_list_without_graph (
@@ -60,6 +60,18 @@ def test_list_without_graph(
60
60
assert set (g .graph_name for g in result ) == {sample_graph .name (), g2 .name ()}
61
61
62
62
63
+ def test_drop (catalog_endpoints : CatalogArrowEndpoints , sample_graph : Graph ) -> None :
64
+ res = catalog_endpoints .drop (sample_graph )
65
+
66
+ assert res .graph_name == sample_graph .name ()
67
+ assert len (catalog_endpoints .list ()) == 0
68
+
69
+
70
+ def test_drop_nonexistent (catalog_endpoints : CatalogArrowEndpoints ) -> None :
71
+ with pytest .raises (ArrowKeyError , match = "does not exist on database" ):
72
+ catalog_endpoints .drop ("nonexistent" , fail_if_missing = True )
73
+
74
+
63
75
def test_projection (arrow_client : AuthenticatedArrowClient , query_runner : QueryRunner ) -> None :
64
76
try :
65
77
endpoints = CatalogArrowEndpoints (arrow_client , query_runner )
@@ -75,7 +87,7 @@ def test_projection(arrow_client: AuthenticatedArrowClient, query_runner: QueryR
75
87
76
88
assert len (endpoints .list ("g" )) == 1
77
89
finally :
78
- arrow_client . do_action ( "v2/graph. drop" , json . dumps ({ "graphName" : "g" }). encode ( "utf-8" ) )
90
+ endpoints . drop ( "g" )
79
91
80
92
81
93
def test_graph_filter (catalog_endpoints : CatalogArrowEndpoints , sample_graph : Graph ) -> None :
@@ -90,6 +102,4 @@ def test_graph_filter(catalog_endpoints: CatalogArrowEndpoints, sample_graph: Gr
90
102
assert result .graph_name == "filtered"
91
103
assert result .project_millis >= 0
92
104
finally :
93
- catalog_endpoints ._arrow_client .do_action (
94
- "v2/graph.drop" , json .dumps ({"graphName" : "filtered" }).encode ("utf-8" )
95
- )
105
+ catalog_endpoints .drop ("filtered" )
0 commit comments