Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkminder committed May 5, 2022
1 parent 658cb60 commit d1da250
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
20 changes: 10 additions & 10 deletions tests/integration/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pytest

from rel2graph import Converter
from rel2graph.relational_modules.pandas import PandasDataFrameIterator
from rel2graph.relational_modules.pandas import PandasDataframeIterator
from rel2graph import IteratorIterator
from mock_graph import MockGraph
from helpers import compare, update_matcher, StateRecoveryException
Expand Down Expand Up @@ -43,7 +43,7 @@ def graph_wpr():
(iris, flower_only_result)]
)
def test_single_type(graph, data, result, workers):
iterator = PandasDataFrameIterator(data[1], data[0])
iterator = PandasDataframeIterator(data[1], data[0])
converter = Converter(schema_file_name, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run
Expand All @@ -59,14 +59,14 @@ def test_single_type(graph, data, result, workers):
)
def test_node_update(graph, initial_data, data, result, workers):
# initial data
iterator = PandasDataFrameIterator(initial_data[1], initial_data[0])
iterator = PandasDataframeIterator(initial_data[1], initial_data[0])
converter = Converter(schema_file_name, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run initial data
converter()

# updated data
iterator = PandasDataFrameIterator(data[1], data[0])
iterator = PandasDataframeIterator(data[1], data[0])
converter = Converter(schema_file_name, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run updated data
Expand All @@ -82,8 +82,8 @@ def test_node_update(graph, initial_data, data, result, workers):
)
def test_two_types(graph, data_type_1, data_type_2, result, workers):
iterator = IteratorIterator([
PandasDataFrameIterator(data_type_1[1], data_type_1[0]),
PandasDataFrameIterator(data_type_2[1], data_type_2[0])
PandasDataframeIterator(data_type_1[1], data_type_1[0]),
PandasDataframeIterator(data_type_2[1], data_type_2[0])
])
converter = Converter(schema_file_name, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
Expand All @@ -100,8 +100,8 @@ def test_two_types(graph, data_type_1, data_type_2, result, workers):
)
def test_state_recovery(graph, data_type_1, data_type_2, result, workers):
iterator = IteratorIterator([
PandasDataFrameIterator(data_type_1[1], data_type_1[0]+"StateRecovery"),
PandasDataFrameIterator(data_type_2[1], data_type_2[0]+"StateRecovery")
PandasDataframeIterator(data_type_1[1], data_type_1[0]+"StateRecovery"),
PandasDataframeIterator(data_type_2[1], data_type_2[0]+"StateRecovery")
])
converter = Converter(schema_file_name, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
Expand All @@ -121,8 +121,8 @@ def test_state_recovery(graph, data_type_1, data_type_2, result, workers):
)
def test_parallel_relations(graph_wpr, data_type_1, data_type_2, result, workers):
iterator = IteratorIterator([
PandasDataFrameIterator(data_type_1[1], data_type_1[0]+"Parallel"),
PandasDataFrameIterator(data_type_2[1], data_type_2[0]+"Parallel")
PandasDataframeIterator(data_type_1[1], data_type_1[0]+"Parallel"),
PandasDataframeIterator(data_type_2[1], data_type_2[0]+"Parallel")
])
converter = Converter(schema_file_name, iterator, graph_wpr, num_workers=workers)
update_matcher(graph_wpr) #REQUIRED to use mock matcher
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from rel2graph import Converter
from rel2graph import AttributeFactoryWrapper, SubgraphFactoryWrapper
from rel2graph.core.graph_elements import Node, Relation, Subgraph
from rel2graph.relational_modules.pandas import PandasDataFrameIterator
from rel2graph.relational_modules.pandas import PandasDataframeIterator
from rel2graph import register_wrapper, register_attribute_postprocessor, register_attribute_preprocessor, register_subgraph_postprocessor, register_subgraph_preprocessor
from rel2graph import Attribute
from mock_graph import MockGraph
Expand Down Expand Up @@ -122,7 +122,7 @@ def construct(self, resource):
[1,5]
)
def test_attr_pre(graph, input, workers):
iterator = PandasDataFrameIterator(input, "ATTRPRE")
iterator = PandasDataframeIterator(input, "ATTRPRE")
converter = Converter(schema_file, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run
Expand All @@ -139,7 +139,7 @@ def test_attr_pre(graph, input, workers):
[1,5]
)
def test_attr_post(graph, input, workers):
iterator = PandasDataFrameIterator(input, "ATTRPOST")
iterator = PandasDataframeIterator(input, "ATTRPOST")
converter = Converter(schema_file, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run
Expand All @@ -158,7 +158,7 @@ def test_attr_post(graph, input, workers):
[1,5]
)
def test_attr_wrapper(graph, input, workers):
iterator = PandasDataFrameIterator(input, "ATTRWRAPPER")
iterator = PandasDataframeIterator(input, "ATTRWRAPPER")
converter = Converter(schema_file, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run
Expand All @@ -174,7 +174,7 @@ def test_attr_wrapper(graph, input, workers):
[1,5]
)
def test_subgraph_pre(graph, input, workers):
iterator = PandasDataFrameIterator(input, "SGPRE")
iterator = PandasDataframeIterator(input, "SGPRE")
converter = Converter(schema_file, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run
Expand All @@ -194,7 +194,7 @@ def test_subgraph_pre(graph, input, workers):
[1,5]
)
def test_subgraph_post(graph, input, workers):
iterator = PandasDataFrameIterator(input, "SGPOST")
iterator = PandasDataframeIterator(input, "SGPOST")
converter = Converter(schema_file, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run
Expand All @@ -216,7 +216,7 @@ def test_subgraph_post(graph, input, workers):
[1,5]
)
def test_subgraph_wrapper(graph, input, workers):
iterator = PandasDataFrameIterator(input, "SGWRAPPER")
iterator = PandasDataframeIterator(input, "SGWRAPPER")
converter = Converter(schema_file, iterator, graph, num_workers=workers)
update_matcher(graph) #REQUIRED to use mock matcher
# run
Expand Down
11 changes: 9 additions & 2 deletions tests/unit/py2neo_extensions/test_graphwpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@
authors: Julian Minder
"""
from py2neo.errors import ConnectionUnavailable
import os
import pytest
from rel2graph.py2neo_extensions import GraphWithParallelRelations
from py2neo import Relationship, Node

@pytest.fixture
def graphwpr():
# Check if custom port
try:
graphwpr = GraphWithParallelRelations()
except ConnectionUnavailable as e:
port = os.environ["NEO4J PORT"]
except KeyError:
port = 7687
# Initialise graph
try:
graphwpr = GraphWithParallelRelations(scheme="bolt", host="localhost", port=port)
except ConnectionUnavailable:
raise ConnectionUnavailable("These tests need a running local instance of neo4j...")
graphwpr.delete_all()
yield graphwpr
Expand Down

0 comments on commit d1da250

Please sign in to comment.