Skip to content

Commit

Permalink
add unit test for UndirectedGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
dpark01 committed Mar 18, 2024
1 parent 3c56bbb commit f5dedea
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/unit/test_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,37 @@ def test_non_failure(self):
self.assertEqual(out, out.upper())


class TestUndirectedGraph(unittest.TestCase):
def test_simple(self):
g = assembly.UndirectedGraph()
g.add_edge('a', 'b')
g.add_edge('a', 'c')
g.add_edge('b', 'd')
actual = list(sorted(g.get_clusters()))
self.assertEqual(actual, [{'a', 'b', 'c', 'd'}])

def test_disconnected(self):
g = assembly.UndirectedGraph()
g.add_edge('a', 'b')
g.add_edge('c', 'd')
actual = list(sorted(g.get_clusters()))
self.assertEqual(actual, [{'a', 'b'}, {'c', 'd'}])

def test_both(self):
g = assembly.UndirectedGraph()
g.add_edge(1, 2)
g.add_edge(11,12)
g.add_edge(18,15)
g.add_node(12)
g.add_node(22)
g.add_node(55)
g.add_edge(25,22)
g.add_edge(7,2)
g.add_edge(12,18)
actual = list(sorted(g.get_clusters()))
self.assertEqual(actual, [{1, 2, 7}, {11, 12, 15, 18}, {22, 25}, {55}])


class TestOrderAndOrient(TestCaseWithTmp):
''' Test the MUMmer-based order_and_orient command '''

Expand Down

0 comments on commit f5dedea

Please sign in to comment.