Skip to content

Commit

Permalink
Remove tests for unsupported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentinD committed Oct 8, 2024
1 parent 0f48a07 commit a6c3198
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 134 deletions.
4 changes: 2 additions & 2 deletions graphdatascience/graph_data_science.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def __init__(
warnings.warn(
DeprecationWarning(
f"Client does not support the given server version `{self._server_version}`."
+ "We recommend to either update the GDS server version or use a compatible version of the `graphdatascience` package."
+ "Please refer to the compatibility matrix at https://neo4j.com/docs/graph-data-science-client/current/installation/#python-client-system-requirements."
+ " We recommend to either update the GDS server version or use a compatible version of the `graphdatascience` package."
+ " Please refer to the compatibility matrix at https://neo4j.com/docs/graph-data-science-client/current/installation/#python-client-system-requirements."
)
)

Expand Down
2 changes: 1 addition & 1 deletion graphdatascience/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from graphdatascience.session.dbms_connection_info import DbmsConnectionInfo

# Should mirror the latest GDS server version under development.
DEFAULT_SERVER_VERSION = ServerVersion(2, 6, 0)
DEFAULT_SERVER_VERSION = ServerVersion(2, 10, 0)

QueryResult = Union[DataFrame, Exception]
QueryResultMap = Dict[str, QueryResult] # Substring -> QueryResult
Expand Down
2 changes: 1 addition & 1 deletion graphdatascience/tests/unit/test_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)


@pytest.mark.parametrize("server_version", [ServerVersion(2, 2, 0)]) # Something later than 2.1.0
@pytest.mark.parametrize("server_version", [ServerVersion(2, 10, 0)]) # Something later than 2.1.0
def test_incompatible_server_version(runner: QueryRunner, gds: GraphDataScience) -> None:
G = Graph("dummy", runner)
with pytest.raises(
Expand Down
97 changes: 19 additions & 78 deletions graphdatascience/tests/unit/test_graph_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from pandas import DataFrame

from graphdatascience.graph_data_science import GraphDataScience
from graphdatascience.server_version.server_version import ServerVersion

from .conftest import CollectingQueryRunner


@pytest.mark.parametrize("server_version", [ServerVersion(2, 1, 0)])
def test_graph_project_based_construct_without_arrow(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
nodes = DataFrame(
{
Expand All @@ -28,54 +26,22 @@ def test_graph_project_based_construct_without_arrow(runner: CollectingQueryRunn
runner.add__mock_result("gds.debug.sysInfo", DataFrame([{"gdsEdition": "Unlicensed"}]))
gds.graph.construct("hello", nodes, relationships, concurrency=2)

expected_node_query = "UNWIND $nodes as node RETURN node[0] as id, node[1] as labels, node[2] as propA"
expected_relationship_query = (
"UNWIND $relationships as relationship RETURN "
"relationship[0] as source, relationship[1] as target, "
"relationship[2] as type, relationship[3] as relPropA"
)
expected_proc_query = (
"CALL gds.graph.project.cypher("
"$graph_name, "
"$node_query, "
"$relationship_query, "
"{readConcurrency: $read_concurrency, parameters: { nodes: $nodes, relationships: $relationships }})"
expected_query = (
"UNWIND $data AS data WITH data, "
"CASE WHEN data[6] THEN data[5] ELSE null END AS sourceNodeLabels, "
"CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType, "
"CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId, "
"\nCASE WHEN data[8] THEN data[7] ELSE null END AS sourceNodeProperties, "
"\nCASE WHEN data[1] THEN data[0] ELSE null END AS relationshipProperties "
"RETURN gds.graph.project($graph_name, data[4], targetNodeId, {sourceNodeLabels: sourceNodeLabels, targetNodeLabels: NULL, sourceNodeProperties: sourceNodeProperties, targetNodeProperties: NULL, relationshipType: relationshipType, relationshipProperties: relationshipProperties}, $configuration)"
)

assert runner.last_query() == expected_proc_query
assert runner.last_params() == {
"nodes": nodes.values.tolist(),
"relationships": relationships.values.tolist(),
"read_concurrency": 2,
"graph_name": "hello",
"node_query": expected_node_query,
"relationship_query": expected_relationship_query,
}
assert runner.last_query() == expected_query


@pytest.mark.parametrize(
"server_version, tier, target_node_labels, target_node_properties, properties_key, in_between_configs",
[
(ServerVersion(2, 3, 0), ".alpha", "", "", "properties", "}, {"),
(
ServerVersion(2, 4, 0),
"",
", targetNodeLabels: NULL",
", targetNodeProperties: NULL",
"relationshipProperties",
", ",
),
],
ids=["2.3.0 - Alpha Cypher Aggregation", "2.4.0 - New Cypher projection"],
)
def test_multi_df(
runner: CollectingQueryRunner,
gds: GraphDataScience,
tier: str,
target_node_labels: str,
target_node_properties: str,
properties_key: str,
in_between_configs: str,
) -> None:
nodes = [
DataFrame({"nodeId": [0, 1], "labels": ["a", "a"], "property": [6.0, 7.0]}),
Expand All @@ -99,13 +65,12 @@ def test_multi_df(
" CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType,"
" CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId,"
" CASE WHEN data[8] THEN data[7] ELSE null END AS sourceNodeProperties,"
f" CASE WHEN data[1] THEN data[0] ELSE null END AS {properties_key}"
f" RETURN gds{tier}.graph.project("
" CASE WHEN data[1] THEN data[0] ELSE null END AS relationshipProperties"
" RETURN gds.graph.project("
"$graph_name, data[4], targetNodeId, {"
f"sourceNodeLabels: sourceNodeLabels{target_node_labels}, "
f"sourceNodeProperties: sourceNodeProperties{target_node_properties}"
f"{in_between_configs}"
f"relationshipType: relationshipType, {properties_key}: {properties_key}"
"sourceNodeLabels: sourceNodeLabels, targetNodeLabels: NULL, "
"sourceNodeProperties: sourceNodeProperties, targetNodeProperties: NULL, "
"relationshipType: relationshipType, relationshipProperties: relationshipProperties"
"}, $configuration)"
)

Expand All @@ -131,29 +96,9 @@ def test_multi_df(
}


@pytest.mark.parametrize(
"server_version, tier, target_node_labels, target_node_properties, properties_key, in_between_configs",
[
(ServerVersion(2, 3, 0), ".alpha", "", "", "properties", "}, {"),
(
ServerVersion(2, 4, 0),
"",
", targetNodeLabels: NULL",
", targetNodeProperties: NULL",
"relationshipProperties",
", ",
),
],
ids=["2.3.0 - Alpha Cypher Aggregation", "2.4.0 - New Cypher projection"],
)
def test_graph_aggregation_based_construct_without_arrow(
runner: CollectingQueryRunner,
gds: GraphDataScience,
tier: str,
target_node_labels: str,
target_node_properties: str,
properties_key: str,
in_between_configs: str,
) -> None:
nodes = DataFrame(
{
Expand Down Expand Up @@ -184,13 +129,12 @@ def test_graph_aggregation_based_construct_without_arrow(
" CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType,"
" CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId,"
" CASE WHEN data[8] THEN data[7] ELSE null END AS sourceNodeProperties,"
f" CASE WHEN data[1] THEN data[0] ELSE null END AS {properties_key}"
f" RETURN gds{tier}.graph.project("
" CASE WHEN data[1] THEN data[0] ELSE null END AS relationshipProperties"
" RETURN gds.graph.project("
"$graph_name, data[4], targetNodeId, {"
f"sourceNodeLabels: sourceNodeLabels{target_node_labels}, "
f"sourceNodeProperties: sourceNodeProperties{target_node_properties}"
f"{in_between_configs}"
f"relationshipType: relationshipType, {properties_key}: {properties_key}"
"sourceNodeLabels: sourceNodeLabels, targetNodeLabels: NULL, "
"sourceNodeProperties: sourceNodeProperties, targetNodeProperties: NULL, "
"relationshipType: relationshipType, relationshipProperties: relationshipProperties"
"}, $configuration)"
)

Expand All @@ -213,7 +157,6 @@ def test_graph_aggregation_based_construct_without_arrow(
}


@pytest.mark.parametrize("server_version", [ServerVersion(2, 3, 0)])
def test_graph_aggregation_based_construct_without_arrow_with_overlapping_property_columns(
runner: CollectingQueryRunner, gds: GraphDataScience
) -> None:
Expand Down Expand Up @@ -242,7 +185,6 @@ def test_graph_aggregation_based_construct_without_arrow_with_overlapping_proper
gds.graph.construct("hello", nodes, relationships, concurrency=2)


@pytest.mark.parametrize("server_version", [ServerVersion(2, 1, 0)])
def test_graph_construct_validate_df_columns(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
nodes = DataFrame({"nodeIds": [0, 1]})
relationships = DataFrame({"sourceNodeId": [0, 1], "TargetNodeIds": [1, 0]})
Expand All @@ -254,7 +196,6 @@ def test_graph_construct_validate_df_columns(runner: CollectingQueryRunner, gds:
gds.graph.construct("hello", nodes, relationships, concurrency=2)


@pytest.mark.parametrize("server_version", [ServerVersion(2, 1, 0)])
def test_graph_alpha_construct_backward_compat(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
nodes = DataFrame(
{
Expand Down
10 changes: 0 additions & 10 deletions graphdatascience/tests/unit/test_graph_cypher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

from graphdatascience.graph.graph_cypher_runner import GraphCypherRunner
from graphdatascience.graph_data_science import GraphDataScience
from graphdatascience.server_version.server_version import ServerVersion

from .conftest import CollectingQueryRunner


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_simple(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
runner.set__mock_result(DataFrame([[{"graphName": "g", "don't squeeze": "me now"}]]))

Expand All @@ -20,7 +18,6 @@ def test_simple(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
assert runner.last_query() == "MATCH (s)-->(t) RETURN gds.graph.project('g', s, t)"


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_fstring(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
runner.set__mock_result(DataFrame([[{"graphName": "g", "don't squeeze": "me now"}]]))

Expand All @@ -33,7 +30,6 @@ def test_fstring(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
assert runner.last_query() == "MATCH (s)-->(t) RETURN gds.graph.project('g', s, t)"


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_expression(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
runner.set__mock_result(DataFrame([[{"graphName": "gg", "don't squeeze": "me now"}]]))

Expand All @@ -45,7 +41,6 @@ def test_expression(runner: CollectingQueryRunner, gds: GraphDataScience) -> Non
assert runner.last_query() == "WITH 'g' AS suffix MATCH (s)-->(t) RETURN gds.graph.project('g' + suffix, s, t)"


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_with_parameter(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
runner.set__mock_result(DataFrame([[{"graphName": "g", "don't squeeze": "me now"}]]))

Expand All @@ -57,7 +52,6 @@ def test_with_parameter(runner: CollectingQueryRunner, gds: GraphDataScience) ->
assert runner.last_query() == "MATCH (s)-->(t) RETURN gds.graph.project($the_graph, s, t)"


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_with_lots_of_whitespace(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
runner.set__mock_result(DataFrame([[{"graphName": "g", "don't squeeze": "me now"}]]))

Expand All @@ -69,7 +63,6 @@ def test_with_lots_of_whitespace(runner: CollectingQueryRunner, gds: GraphDataSc
assert runner.last_query() == "MATCH (s)-->(t) RETURN gds .graph. project\n(\t'g' ,s, t)"


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_extracting_graph_name(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
runner.set__mock_result(DataFrame([[{"graphName": "the graph", "don't squeeze": "me now"}]]))

Expand All @@ -81,7 +74,6 @@ def test_extracting_graph_name(runner: CollectingQueryRunner, gds: GraphDataScie
assert runner.last_query() == "MATCH (s)-->(t) RETURN gds.graph.project('g', s, t)"


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_with_return_not_being_last(gds: GraphDataScience) -> None:
with pytest.raises(
ValueError,
Expand All @@ -90,7 +82,6 @@ def test_with_return_not_being_last(gds: GraphDataScience) -> None:
gds.graph.cypher.project("MATCH (s)-->(t) RETURN gds.graph.project($graph_name, s, t) AS graph")


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_with_no_return(gds: GraphDataScience) -> None:
with pytest.raises(
ValueError,
Expand All @@ -99,7 +90,6 @@ def test_with_no_return(gds: GraphDataScience) -> None:
gds.graph.cypher.project("MATCH (s)-->(t)")


@pytest.mark.parametrize("server_version", [ServerVersion(2, 4, 0)])
def test_with_multiple_returns(gds: GraphDataScience) -> None:
with pytest.raises(
ValueError,
Expand Down
Loading

0 comments on commit a6c3198

Please sign in to comment.