def test_connect():
n1 = WithParameters(a=1, b=2)
n2 = WithParameters(c=1, d=2)
g = graph.Graph('testgraph', [n1, n2])
not_included = WithParameters(e=1, f=2)
# Errors when trying to link nodes coming from out of the graph
with pytest.raises(exceptions.NodeConnectionError):
g.connect(n1, not_included, 'blabla')
pytest.fail()
with pytest.raises(exceptions.NodeConnectionError):
g.connect(not_included, n2, 'blabla')
pytest.fail()
# Now the correct procedure
assert n2.output_label is None
assert len(g.nxgraph.edges()) == 0
g.connect(n1, n2, 'label')
assert n2.output_label == 'label'
assert len(g.nxgraph.edges()) == 1
评论列表
文章目录