def test_complicate_task5_3(self): leafI = TMTree("leaf", [], 20) leafJ = TMTree("leaf2", [], 15) folderD = TMTree("folderD", [leafI, leafJ], 50) leafE = TMTree("leaf3", [], 35) folderA = TMTree("folderA", [folderD, leafE], 0) leafK = TMTree("leafK", [], 40) leafL = TMTree("leafL", [], 10) folderF = TMTree("folderF", [leafK, leafL], 0) leafG = TMTree("leafG", [], 10) folderB = TMTree("folderB", [folderF, leafG], 0) leafO = TMTree("leafO", [], 20) leafP = TMTree("leafP", [], 20) folderM = TMTree("leafM", [leafO, leafP], 40) leafN = TMTree("leafN", [], 40) folderH = TMTree("folderH", [folderM, leafN], 0) folderC = TMTree("folderC", [folderH], 0) root = TMTree("root", [folderA, folderB, folderC], 0) root._expanded = True folderA._expanded = True folderB._expanded = True folderC._expanded = True rect = (0, 0, 210, 60) root.update_rectangles(rect) exp = [(0, 0, 35, 60), (35, 0, 35, 60), (70, 0, 60, 50), (70, 50, 60, 10), (130, 0, 80, 60)] temp = root.get_rectangles() assert len(temp) == 5 act = [sub[0] for sub in temp] self.assertCountEqual( act, exp, "For task 5 you should return every leaf in the DISPLAYED tree")
def test_two_qual_height_tree_task5_2(self): leaf = TMTree("leaf", [], 50) leaf2 = TMTree("leaf2", [], 50) leaf3 = TMTree("leaf3", [], 50) leaf4 = TMTree("leaf4", [], 50) internal1 = TMTree("internal1", [leaf, leaf2], 0) internal2 = TMTree("internal2", [leaf3, leaf4], 0) root = TMTree("root", [internal1, internal2], 0) rect = (0, 0, 100, 100) root._expanded = True internal2._expanded = True root.update_rectangles(rect) exp = [(0, 0, 100, 50), (0, 50, 50, 50), (50, 50, 50, 50)] temp = root.get_rectangles() assert len(temp) == 3 act = [sub[0] for sub in temp] self.assertCountEqual( act, exp, "For task 5 you should only return leaf in the DISPLAY tree")
def test_different_direction_task5(self): leaf = TMTree("leaf", [], 50) leaf2 = TMTree("leaf2", [], 30) leaf3 = TMTree("leaf3", [], 70) internal = TMTree("internal", [leaf2, leaf3], 0) root = TMTree("root", [internal, leaf], 0) rect = (0, 0, 210, 160) exp = [(0, 0, 140, 160), (140, 0, 70, 160)] root._expanded = True root.update_rectangles(rect) temp = root.get_rectangles() assert len(temp) == 2 act = [sub[0] for sub in temp] self.assertCountEqual( act, exp, "For task5 you should return every leaf of the displayed tree")