Skip to content

Commit

Permalink
test: exercise node_link_data with invalid data
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Sep 11, 2024
1 parent b10f22e commit b5e2258
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions g2p/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,24 @@ def test_node_link_data(self):
graph = node_link_graph(self.data)
self.assertEqual(node_link_data(graph), self.data)

def test_node_link_graph_errors(self):
with self.assertRaises(ValueError):
node_link_graph({**self.data, "directed": False})
with self.assertRaises(ValueError):
node_link_graph({**self.data, "multigraph": True})
with self.assertRaises(ValueError):
node_link_graph({**self.data, "nodes": "not a list"})
with self.assertRaises(ValueError):
node_link_graph({**self.data, "links": "not a list"})
with self.assertRaises(ValueError):
data = self.data.copy()
del data["nodes"]
node_link_graph(data)
with self.assertRaises(ValueError):
data = self.data.copy()
del data["links"]
node_link_graph(data)

def test_no_duplicates(self):
graph = DiGraph()
graph.add_edge("a", "b")
Expand Down

0 comments on commit b5e2258

Please sign in to comment.