Skip to content

Commit 2790176

Browse files
committed
Fix tests for neo4j 4.x drivers
1 parent a79431e commit 2790176

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

graphdatascience/tests/unit/session/test_dbms_connection_info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ def test_dbms_connection_info_username_password() -> None:
1111
database="neo4j",
1212
)
1313

14-
assert dci.get_auth() == neo4j.basic_auth("neo4j", "password")
14+
auth = dci.get_auth()
15+
16+
assert (auth.principal, auth.credentials) == ("neo4j", "password") # type:ignore
1517

1618

1719
def test_dbms_connection_info_advanced_auth() -> None:

graphdatascience/tests/unit/test_dedicated_sessions.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from datetime import datetime, timedelta, timezone
44
from typing import Optional, cast
55

6-
import neo4j
76
import pytest
87
from pytest_mock import MockerFixture
98

@@ -350,10 +349,13 @@ def test_create_attached_session(mocker: MockerFixture, aura_api: AuraApi) -> No
350349
arrow_authentication = gds_parameters["arrow_authentication"] # type: ignore
351350
del gds_parameters["arrow_authentication"]
352351

352+
dbms_authentication = gds_parameters["db_runner"].pop("auth") # type: ignore
353+
354+
assert (dbms_authentication.principal, dbms_authentication.credentials) == ("dbuser", "db_pw")
355+
353356
assert gds_parameters == { # type: ignore
354357
"db_runner": {
355358
"endpoint": "neo4j+s://ffff0.databases.neo4j.io",
356-
"auth": neo4j.basic_auth("dbuser", "db_pw"),
357359
"aura_ds": True,
358360
"database": None,
359361
"show_progress": False,
@@ -394,10 +396,13 @@ def test_create_standalone_session(mocker: MockerFixture, aura_api: AuraApi) ->
394396
arrow_authentication = gds_credentials["arrow_authentication"] # type: ignore
395397
del gds_credentials["arrow_authentication"]
396398

399+
dbms_authentication = gds_credentials["db_runner"].pop("auth") # type: ignore
400+
401+
assert (dbms_authentication.principal, dbms_authentication.credentials) == ("dbuser", "db_pw")
402+
397403
assert gds_credentials == { # type: ignore
398404
"db_runner": {
399405
"endpoint": "neo4j+s://foo.bar",
400-
"auth": neo4j.basic_auth("dbuser", "db_pw"),
401406
"aura_ds": True,
402407
"database": None,
403408
"show_progress": False,
@@ -442,10 +447,15 @@ def test_get_or_create(mocker: MockerFixture, aura_api: AuraApi) -> None:
442447
del gds_args1["arrow_authentication"]
443448
del gds_args2["arrow_authentication"]
444449

450+
actual_auth_1 = gds_args1["db_runner"].pop("auth") # type: ignore
451+
actual_auth_2 = gds_args2["db_runner"].pop("auth") # type: ignore
452+
453+
assert (actual_auth_1.principal, actual_auth_1.credentials) == ("dbuser", "db_pw")
454+
assert (actual_auth_2.principal, actual_auth_2.credentials) == ("dbuser", "db_pw")
455+
445456
assert gds_args1 == { # type: ignore
446457
"db_runner": {
447458
"endpoint": "neo4j+s://ffff0.databases.neo4j.io",
448-
"auth": neo4j.basic_auth("dbuser", "db_pw"),
449459
"aura_ds": True,
450460
"database": None,
451461
"show_progress": False,
@@ -456,6 +466,7 @@ def test_get_or_create(mocker: MockerFixture, aura_api: AuraApi) -> None:
456466
),
457467
"session_id": "ffff0-ffff1",
458468
}
469+
459470
assert gds_args1 == gds_args2
460471

461472
assert isinstance(arrow_authentication, AuraApiTokenAuthentication)

0 commit comments

Comments
 (0)