Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxins committed Apr 24, 2024
1 parent 714191d commit 34bbf58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/digraph/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def test_remove_nodes_from_with_invalid_index(self):
self.assertEqual(["a"], res)
self.assertEqual([0], dag.node_indexes())

def test_has_node(self):
dag = rustworkx.PyDAG()
node_a = dag.add_node("a")
self.assertTrue(dag.has_node(node_a))
self.assertFalse(dag.has_node(node_a + 1))

def test_remove_nodes_retain_edges_single_edge(self):
dag = rustworkx.PyDAG()
node_a = dag.add_node("a")
Expand All @@ -85,7 +91,6 @@ def test_remove_nodes_retain_edges_single_edge(self):
res = dag.nodes()
self.assertEqual(["a", "c"], res)
self.assertEqual([0, 2], dag.node_indexes())
self.assertTrue(dag.has_node(node_a))
self.assertTrue(dag.has_edge(node_a, node_c))
self.assertEqual(dag.get_all_edge_data(node_a, node_c), ["Edgy"])

Expand All @@ -98,7 +103,6 @@ def test_remove_nodes_retain_edges_single_edge_outgoing_weight(self):
res = dag.nodes()
self.assertEqual(["a", "c"], res)
self.assertEqual([0, 2], dag.node_indexes())
self.assertTrue(dag.has_node(node_a))
self.assertTrue(dag.has_edge(node_a, node_c))
self.assertEqual(dag.get_all_edge_data(node_a, node_c), ["Edgy_mk2"])

Expand Down
6 changes: 6 additions & 0 deletions tests/graph/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,9 @@ def test_remove_node_delitem_invalid_index(self):
res = graph.nodes()
self.assertEqual(["a", "b", "c"], res)
self.assertEqual([0, 1, 2], graph.node_indexes())

def test_has_node(self):
graph = rustworkx.PyGraph()
node_a = graph.add_node("a")
self.assertTrue(graph.has_node(node_a))
self.assertFalse(graph.has_node(node_a + 1))

0 comments on commit 34bbf58

Please sign in to comment.