def test_obtain_employees() -> None:
    o = Organization()
    e1 = Leader(1, 'Holly', '', 1, 1, 'Department')
    o.add_employee(e1)
    e2 = Employee(2, 'Ivan', '', 1, 1)
    o.add_employee(e2, 1)
    e3 = Employee(3, 'Kevin', '', 1, 1)
    o.add_employee(e3, 2)
    e4 = Employee(4, 'Joe', 'Mama', 1, 100)
    o.add_employee(e4, 2)
    e5 = Employee(5, 'Linda', '', 1, 1)
    o.add_employee(e5, 4)
    assert e1.get_direct_subordinates() == [e2]
    assert e2.get_superior() == e1
    assert e2.get_direct_subordinates() == [e3, e4]
    assert e3.get_superior() == e2
    assert e4.get_superior() == e2
    assert e3.get_direct_subordinates() == []
    assert e4.get_direct_subordinates() == [e5]
    assert e5.get_superior() == e4
    e4.obtain_subordinates([2])
    assert o.get_head() == e1
    assert e1.get_direct_subordinates() == [e3, e4]
    assert e3.get_superior() == e1
    assert e4.get_superior() == e1
    assert e3.get_direct_subordinates() == []
    assert e4.get_direct_subordinates() == [e2, e5]
    assert e2.get_superior() == e4
    assert e5.get_superior() == e4
Example #2
0
def test_swap_up_simple() -> None:
    e1 = Employee(1, "Emma Ployee", "Worker", 10000, 50)
    e2 = Leader(2, "Sue Perior", "Manager", 20000, 30, "Department")
    e3 = Leader(3, "Bigg Boss", "CEO", 50000, 60, "Company")
    e1.become_subordinate(e2)
    e2.become_subordinate(e3)
    new_e1 = e1.swap_up()
    assert isinstance(new_e1, Leader)
    new_e2 = new_e1.get_direct_subordinates()[0]
    assert isinstance(new_e2, Employee)
    assert new_e1.position == 'Manager'
    assert new_e1.eid == 1
    assert e3.get_direct_subordinates()[0] is new_e1
def test_fire_under_rating_simple() -> None:
    e1 = Leader(1, "Sarah", "CEO", 500000, 99, "Some Corp.")
    e2 = Employee(2, "Sandra", "Secretary", 20000, 99)
    e3 = Employee(3, "Sofia", "Manager", 25000, 89)
    e4 = Employee(4, "Senya", "Grunt", 5000, 89)
    e5 = Employee(5, "Sylvia", "Grunt", 5000, 89)
    o = Organization()
    o.add_employee(e1)
    o.add_employee(e2, 1)
    o.add_employee(e3, 1)
    o.add_employee(e4, 3)
    o.add_employee(e5, 3)
    o.fire_under_rating(99)
    assert o.get_head() == e1
    assert e1.get_direct_subordinates() == [e2]
def test_fire_lowest_rated_employee_tie() -> None:
    e1 = Leader(1, "Sarah", "CEO", 500000, 99, "Some Corp.")
    e2 = Employee(2, "Sandra", "Secretary", 20000, 99)
    e3 = Employee(3, "Sofia", "Manager", 25000, 89)
    e4 = Employee(4, "Senya", "Grunt", 5000, 89)
    e5 = Employee(5, "Sylvia", "Grunt", 5000, 89)
    o = Organization()
    o.add_employee(e1)
    o.add_employee(e2, 1)
    o.add_employee(e3, 1)
    o.add_employee(e4, 3)
    o.add_employee(e5, 3)
    o.fire_lowest_rated_employee()
    assert e1.get_direct_subordinates() == [e2, e4, e5]
    assert e4.get_superior() == e1
    assert e5.get_superior() == e1
Example #5
0
def test_get_direct_subordinates_advanced() -> None:
    e1 = Employee(1, "Emma Ployee", "Worker", 10000, 50)
    e2 = Employee(2, "Sue Perior", "Manager", 20000, 30)
    e3 = Employee(3, "Robocop", "Worker", 20000, 30)
    e4 = Leader(4, "Sarah", "CEO", 20000, 30, "Some Corp.")
    e5 = Employee(5, "Sofia", "Worker", 20000, 30)
    e6 = Employee(6, "Terry", "Worker", 20000, 30)
    e7 = Employee(7, "Odysseus", "Worker", 20000, 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 e2.get_direct_subordinates() == [e1, e3, e5]
    assert e4.get_direct_subordinates() == [e2, e6, e7]
    assert e1.get_direct_subordinates() == []
Example #6
0
def test_obtain_subordinates_simple() -> None:
    e1 = Leader(1, "Sarah", "CEO", 500000, 30, "Some Corp.")
    e2 = Employee(2, "Sandra", "Secretary", 20000, 30)
    e3 = Employee(3, "Sofia", "Manager", 25000, 40)
    e4 = Employee(4, "Senya", "Grunt", 5000, 30)
    e5 = Employee(5, "Sylvia", "Grunt", 5000, 40)
    e2.become_subordinate(e1)
    e3.become_subordinate(e1)
    e4.become_subordinate(e3)
    e5.become_subordinate(e3)
    new_head = e2.obtain_subordinates([3, 5])
    assert new_head == e1
    assert e2.get_direct_subordinates() == [e3, e5]
    assert e1.get_direct_subordinates() == [e2, e4]
    assert e3.get_superior() == e2
    assert e5.get_superior() == e2
    assert e2.get_superior() == e1
    assert e4.get_superior() == e1