def test_two_identical_composites(self): paths = [ ['a', 'a1', 'a2', 'a3'], ['a', 'a1', 'a2', 'a3'], ] expected = [ ('a', [ ('a1', [ ('a2', [ ('a3', []) ]) ]) ]), ] assert join_paths(paths) == expected
def test_two_different_composites(self): paths = [ ['a', 'a1', 'a2', 'a3'], ['diff', 'a1', 'a2', 'a3'], ] expected = [ ('a', [ ('a1', [ ('a2', [ ('a3', []) ]) ]) ]), ('diff', [ ('a1', [ ('a2', [ ('a3', []) ]) ]) ]) ] assert join_paths(paths) == expected
def test_two_composites_first_2_identical(self): paths = [ ['a', 'a1', 'diff', 'a3'], ['a', 'a1', 'a2', 'a3'], ] expected = [ ('a', [ ('a1', [ ('a2', [ ('a3', []) ]), ('diff', [ ('a3', []) ]), ]), ]), ] assert join_paths(paths) == expected
def test_multiple_with_same_root(self): paths = [ ['a', 'a2', 'a22'], ['a', 'a1', 'a12'], ['a', 'a1', 'a11', 'a111', 'a1111'], ['a', 'a1', 'a11'], ['a', 'a1', 'a12', 'a121'], ['a', 'a1', 'a12'], # duplicate, should not matter ['a', 'a2', 'a21'], ] expected = [ ('a', [ ('a1', [ ('a11', [ ('a111', [ ('a1111', []) ]) ]), ('a12', [ ('a121', []) ]), ]), ('a2', [ ('a21', []), ('a22', []), ]) ]), ] assert join_paths(paths) == expected
def test_multiple_with_separate_roots(self): paths = [ ['b', 'b1', 'b12'], ['a', 'a2', 'a22'], ['a', 'a1', 'a12'], ['a', 'a1', 'a11', 'a111', 'a1111'], ['a', 'a1', 'a11'], ['a', 'a1', 'a12', 'a121'], ['a', 'a1', 'a12'], ['a', 'a2', 'a21'], ['b', 'b1', 'b11', 'b111'], ['c', 'c1', 'c11', 'c111'], ['b', 'b2', 'b21'], ['b', 'b1', 'b11'], ] expected = [ ('a', [ ('a1', [ ('a11', [ ('a111', [ ('a1111', []) ]) ]), ('a12', [ ('a121', []) ]), ]), ('a2', [ ('a21', []), ('a22', []), ]) ]), ('b', [ ('b1', [ ('b11', [ ('b111', []) ]), ('b12', []), ]), ('b2', [ ('b21', []) ]), ]), ('c', [ ('c1', [ ('c11', [ ('c111', []) ]) ]) ]), ] assert join_paths(paths) == expected
def test_empty(self): assert join_paths([]) == []
def test_single_composite_3_levels(self): paths = [['a', 'a1', 'a2', 'a3']] expected = [ ('a', [ ('a1', [ ('a2', [ ('a3', []) ]) ]) ]) ] assert join_paths(paths) == expected
def test_two_different_leaves(self): paths = [['a'], ['b']] expected = [ ('a', []), ('b', []) ] assert join_paths(paths) == expected
def test_two_identical_leaves(self): paths = [['a'], ['a']] expected = [ ('a', []) ] assert join_paths(paths) == expected
def test_single_leaf(self): paths = ['a'] expected = [ ('a', []) ] assert join_paths(paths) == expected