Skip to content

Commit 4c10726

Browse files
Add test for the ArrowQueryRunner constructor
Co-Authored-By: Jonatan Jäderberg <jonatan.jaderberg@gmail.com>
1 parent e345a22 commit 4c10726

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
from pandas import DataFrame
3+
from pyarrow.flight import FlightUnavailableError
4+
5+
from .conftest import CollectingQueryRunner
6+
from graphdatascience.query_runner.arrow_query_runner import ArrowQueryRunner
7+
from graphdatascience.server_version.server_version import ServerVersion
8+
9+
10+
@pytest.mark.parametrize("server_version", [ServerVersion(2, 6, 0)])
11+
def test_create(runner: CollectingQueryRunner) -> None:
12+
runner.set__mock_result(DataFrame([{"running": True, "listenAddress": "localhost:1234"}]))
13+
14+
arrow_runner = ArrowQueryRunner.create(runner)
15+
16+
assert isinstance(arrow_runner, ArrowQueryRunner)
17+
18+
with pytest.raises(FlightUnavailableError, match=".+ failed to connect .+ ipv4:127.0.0.1:1234: .+"):
19+
arrow_runner._flight_client.list_actions()
20+
21+
22+
@pytest.mark.parametrize("server_version", [ServerVersion(2, 6, 0)])
23+
def test_return_fallback_when_arrow_is_not_running(runner: CollectingQueryRunner) -> None:
24+
runner.set__mock_result(DataFrame([{"running": False, "listenAddress": "localhost:1234"}]))
25+
26+
arrow_runner = ArrowQueryRunner.create(runner)
27+
28+
assert arrow_runner is runner
29+
30+
31+
@pytest.mark.parametrize("server_version", [ServerVersion(2, 6, 0)])
32+
def test_create_with_provided_connection(runner: CollectingQueryRunner) -> None:
33+
runner.set__mock_result(DataFrame([{"running": True, "listenAddress": "localhost:1234"}]))
34+
35+
arrow_runner = ArrowQueryRunner.create(runner, connection_string_override="localhost:4321")
36+
37+
assert isinstance(arrow_runner, ArrowQueryRunner)
38+
39+
with pytest.raises(FlightUnavailableError, match=".+ failed to connect .+ ipv4:127.0.0.1:4321: .+"):
40+
arrow_runner._flight_client.list_actions()

0 commit comments

Comments
 (0)