From b5e22587bfcb407d6057cf364ab03ee9399aa006 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Wed, 11 Sep 2024 11:49:24 -0400 Subject: [PATCH] test: exercise node_link_data with invalid data --- g2p/tests/test_network.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/g2p/tests/test_network.py b/g2p/tests/test_network.py index bbc6e514..da7136be 100755 --- a/g2p/tests/test_network.py +++ b/g2p/tests/test_network.py @@ -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")