def test_lca(self): """ Test LCA """ n1 = Diagram() n1.id = 'n1' n2 = Element('a', id='n2') n3 = Element('a', id='n3') n1.children.extend((n2, n3)) n2.parent = n1 n3.parent = n1 p = lca(n1, n2, n3) self.assertEquals('n1', p.id)
def test_lca_order(self): """ Test LCA ordering """ n1 = Diagram() n1.id = 'd1' n2 = Element('a', id='n2') n3 = PackagingElement('a', id='dc2') n4 = Element('a', id='n4') n5 = Element('a', id='n5') n1.children.extend((n2, n3)) n2.parent = n1 n3.parent = n1 n3.children.extend((n4, n5)) n4.parent = n3 n5.parent = n3 p = lca(n1, n4, n5) self.assertEquals('dc2', p.id)
def test_unwind(self): """ Test unwind """ n1 = Diagram() n1.id = 'n1' n2 = PackagingElement('a', id='n2') n3 = PackagingElement('a', id='n3') n4 = Element('a', id='n4') n1.children.extend((n2, n3)) n2.children.append(n4) n2.parent = n1 n3.parent = n1 n4.parent = n2 self.assertEquals([n1, n2, n4, n3], list(unwind(n1)))