def test_get_closest_common_superior() -> None: e = Employee(1, 'Name1', 'Pos1', 10, 10) e1 = Employee(2, 'Name2', 'Pos2', 10, 10) e3 = Employee(3, 'Name3', 'Pos3', 10, 10) e1.become_subordinate(e) e3.become_subordinate(e) assert e1.get_closest_common_superior(3).name == e.name e4 = Employee(4, 'Name4', 'Pos4', 10, 10) e4.become_subordinate(e1) assert e4.get_closest_common_superior(3).name == e.name e5 = Employee(5, 'Name5', 'Pos5', 10, 10) e5.become_subordinate(e1) e6 = Employee(6, 'Name6', 'Pos6', 10, 10) e6.become_subordinate(e5) assert e5.get_closest_common_superior(4).name == 'Name2' assert e1.get_closest_common_superior(1) == e
def test_get_closest_common_superior_simple() -> None: e1 = Employee(1, "Emma Ployee", "Worker", 10000, 50) e2 = Employee(2, "Sue Perior", "Manager", 20000, 30) e3 = Leader(3, "Bigg Boss", "CEO", 50000, 60, "Some Corp.") e1.become_subordinate(e3) e2.become_subordinate(e3) superior = e1.get_closest_common_superior(3) assert superior.eid == 3
def test_employee_general() -> None: e1 = Employee(1, "e1", "a", 1, 50) e2 = Employee(2, "e2", "a", 1, 50) e3 = Employee(3, "e3", "a", 1, 50) e4 = Employee(4, "e4", "a", 1, 50) e5 = Employee(5, "e5", "a", 1, 50) e6 = Employee(6, "e6", "a", 1, 50) e7 = Employee(7, "e7", "a", 1, 50) e7.become_subordinate(e5) e5.become_subordinate(e2) e4.become_subordinate(e2) e2.become_subordinate(e1) e3.become_subordinate(e1) e6.become_subordinate(e3) assert e6.get_all_subordinates() == [] assert e2.get_all_subordinates() == [e4, e5, e7] assert e2.get_direct_subordinates() == [e4, e5] assert e7.get_organization_head() == e1 assert e1.get_organization_head() == e1 assert e7.get_closest_common_superior(4) == e2 assert e2.get_closest_common_superior(4) == e2 assert e2.get_closest_common_superior(7) == e2 # assert e7.become_leader("seven") == e1 assert len(e5.get_direct_subordinates()) == 1 e7 = e5.get_direct_subordinates()[0] # assert isinstance(e7, Leader) assert e1.get_highest_rated_subordinate() == e2 assert e5.get_highest_rated_subordinate().eid == 7 # assert e7.get_department_leader() == e7 # assert e2.become_leader('two') == e1 e2 = e1.get_direct_subordinates()[0] assert e2.eid == 2 assert e1.become_leader('one').eid == 1 e1 = e2.become_leader(3)
def test_get_closest_common_superior_other_is_superior() -> None: e1 = Employee(1, "Emma Ployee", "Worker", 10000, 50) e2 = Employee(2, "Sue Perior", "Manager", 50000, 30) e3 = Employee(3, "Robocop", "Worker", 20000, 30) e4 = Leader(4, "Sarah", "CEO", 500000, 30, "Some Corp.") e5 = Employee(5, "Sofia", "Worker", 10000, 30) e6 = Employee(6, "Terry", "Worker", 5000, 30) e7 = Employee(7, "Odysseus", "Worker", 22000, 30) e1.become_subordinate(e2) e3.become_subordinate(e2) e2.become_subordinate(e4) e5.become_subordinate(e2) e6.become_subordinate(e4) e7.become_subordinate(e4) assert e1.get_closest_common_superior(4) == e4
def test_get_closest_common_superior_advanced() -> None: e1 = Employee(1, "Emma Ployee", "Worker", 52000, 50) e2 = Employee(2, "Sue Perior", "Manager", 50000, 30) e3 = Employee(3, "Robocop", "Worker", 20000, 30) e4 = Leader(4, "Sarah", "CEO", 500000, 30, "Some Corp.") e5 = Employee(5, "Sofia", "Worker", 10000, 30) e6 = Employee(6, "Terry", "Worker", 5000, 30) e7 = Employee(7, "Odysseus", "Worker", 62000, 30) e8 = Employee(8, "Sparrow", "Contract Worker", 60000, 30) e9 = Employee(9, "Nick", "Contract Worker", 70000, 30) e10 = Employee(10, "Theseus", "Contract Worker", 80000, 30) e1.become_subordinate(e2) e3.become_subordinate(e2) e2.become_subordinate(e4) e5.become_subordinate(e2) e6.become_subordinate(e4) e7.become_subordinate(e4) e8.become_subordinate(e1) e9.become_subordinate(e1) e10.become_subordinate(e1) assert e10.get_closest_common_superior(7) == e4