Skip to content
Closed
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
24 changes: 19 additions & 5 deletions tests/test_falkordb_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
docker run -d -p 6379:6379 falkordb/falkordb:latest
uv run pytest tests/test_falkordb_integration.py -q

The test auto-skips when the `falkordb` SDK is not installed or no FalkorDB is
reachable, so it is a no-op in the default CI (which runs no external services).
The test auto-skips when the `falkordb` SDK is not installed, no server is
reachable, or the server that answers is not FalkorDB, so it is a no-op in the
default CI (which runs no external services) and on a dev box that already has
a plain Redis on 6379.
Host/port are overridable via FALKORDB_HOST / FALKORDB_PORT.
"""
from __future__ import annotations
Expand All @@ -26,13 +28,25 @@


def _connect():
"""Return a connected FalkorDB client, or skip if none is reachable."""
"""Return a connected FalkorDB client, or skip if none is reachable.

``ping()`` only proves *something* answers on the port. A plain Redis -- or
an SSH tunnel forwarding one -- replies to PING but has no graph module, so
the guard passed and the tests FAILED on `unknown command 'GRAPH.QUERY'`
instead of skipping. ``GRAPH.LIST`` identifies the service rather than mere
liveness: it is read-only, creates no keys, and anything that is not
FalkorDB/RedisGraph rejects it as an unknown command.
"""
try:
db = falkordb.FalkorDB(host=HOST, port=PORT)
db.connection.ping()
return db
except Exception as e: # pragma: no cover - depends on local environment
pytest.skip(f"no FalkorDB reachable at {HOST}:{PORT} ({e})")
pytest.skip(f"no server reachable at {HOST}:{PORT} ({e})")
try:
db.connection.execute_command("GRAPH.LIST")
except Exception as e: # pragma: no cover - depends on local environment
pytest.skip(f"server at {HOST}:{PORT} is not FalkorDB, no graph module ({e})")
return db


@pytest.fixture()
Expand Down