Skip to content

Commit f87c7c9

Browse files
committed
Run >5.21 driver tests based on pytest mark
1 parent 6bb3e8d commit f87c7c9

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

graphdatascience/tests/integration/conftest.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,9 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None:
194194
server_version = gds._server_version
195195
except Exception as e:
196196
print("Could not derive GDS library server version")
197-
gds.close()
198197
raise e
199-
200-
gds.close()
198+
finally:
199+
gds.close()
201200

202201
skip_incompatible_versions = pytest.mark.skip(reason=f"incompatible with GDS server version {server_version}")
203202

@@ -211,3 +210,17 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None:
211210

212211
if "max_exclusive" in kwargs and kwargs["max_exclusive"] <= server_version:
213212
item.add_marker(skip_incompatible_versions)
213+
214+
db_driver_version = Neo4jQueryRunner._NEO4J_DRIVER_VERSION
215+
skip_incompatible_driver_version = pytest.mark.skip(reason=f"incompatible with driver version {db_driver_version}")
216+
217+
for item in items:
218+
for mark in item.iter_markers(name="compatible_with_db_driver"):
219+
kwargs = mark.kwargs
220+
221+
if "min_inclusive" in kwargs and kwargs["min_inclusive"] > db_driver_version:
222+
item.add_marker(skip_incompatible_driver_version)
223+
continue
224+
225+
if "max_exclusive" in kwargs and kwargs["max_exclusive"] <= db_driver_version:
226+
item.add_marker(skip_incompatible_driver_version)

graphdatascience/tests/integration/test_error_handling.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from neo4j import Driver, GraphDatabase
55

66
from graphdatascience import GraphDataScience
7-
from graphdatascience.query_runner.neo4j_query_runner import Neo4jQueryRunner
87
from graphdatascience.server_version.server_version import ServerVersion
98
from graphdatascience.tests.integration.conftest import AUTH, URI
109

@@ -210,20 +209,20 @@ def test_forward_server_side_warning(gds: GraphDataScience) -> None:
210209

211210

212211
@pytest.mark.filterwarnings("ignore: notification warnings are a preview feature")
212+
@pytest.mark.compatible_with_db_driver(min_inclusive=ServerVersion(5, 21, 0))
213213
def test_forward_driver_configured_warning(warning_driver: Driver) -> None:
214-
if Neo4jQueryRunner._NEO4J_DRIVER_VERSION >= ServerVersion(5, 21, 0):
215-
gds = GraphDataScience(warning_driver)
214+
gds = GraphDataScience(warning_driver)
216215

217-
with pytest.raises(Warning, match="The query used a deprecated function: `id`."):
218-
gds.run_cypher("MATCH (n) RETURN id(n)")
216+
with pytest.raises(Warning, match="The query used a deprecated function: `id`."):
217+
gds.run_cypher("MATCH (n) RETURN id(n)")
219218

220219

221220
def test_filter_out_client_related__warning(gds: GraphDataScience) -> None:
222221
gds.graph.drop("g", failIfMissing=False)
223222

224223

225224
@pytest.mark.filterwarnings("ignore: notification warnings are a preview feature")
225+
@pytest.mark.compatible_with_db_driver(min_inclusive=ServerVersion(5, 21, 0))
226226
def test_filter_out_client_related__driver_configured_warning(warning_driver: Driver) -> None:
227-
if Neo4jQueryRunner._NEO4J_DRIVER_VERSION >= ServerVersion(5, 21, 0):
228-
gds = GraphDataScience(warning_driver)
229-
gds.graph.drop("g", failIfMissing=False)
227+
gds = GraphDataScience(warning_driver)
228+
gds.graph.drop("g", failIfMissing=False)

graphdatascience/tests/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ markers =
44
encrypted_only: mark a test as requiring GDS with either bolt or https ssl.policy configured.
55
model_store_location: mark a test as a requiring neo4j config for gds.model.store_location
66
compatible_with: mark a test as only being compatible with certain GDS server versions
7+
compatible_with_db_driver: mark a test as only being compatible with a certain Neo4j driver version
78
skip_on_aura: mark a test to not be run when targeting an AuraDS instance
89
only_on_aura: mark a test to be run only when targeting an AuraDS instance
910
ogb: mark a test as requiring the ogb dependency

0 commit comments

Comments
 (0)