Exemple #1
0
def test_swap_up_repeated() -> None:
    e1 = Leader(1, "Sarah", "CEO", 500000, 30, "Some Corp.")
    e2 = Employee(2, "Sandra", "Secretary", 20000, 30)
    e3 = Leader(3, "Sofia", "Manager", 25000, 30, "Grunts Department")
    e4 = Employee(4, "Senya", "Grunt Alpha", 15000, 30)
    e5 = Employee(5, "Sylvia", "Grunt Beta", 10000, 30)
    e6 = Employee(6, "Scarlett", "Grunt Gamma", 5000, 30)
    e7 = Employee(7, "Samantha", "Grunt Epsilon", 2500, 100)
    e2.become_subordinate(e1)
    e3.become_subordinate(e1)
    e4.become_subordinate(e3)
    e5.become_subordinate(e4)
    e6.become_subordinate(e5)
    e7.become_subordinate(e6)

    new_e7 = e7.swap_up()
    assert new_e7.get_superior() == e5
    assert new_e7.salary == 5000
    assert new_e7.position == "Grunt Gamma"

    for i in range(4):
        new_e7 = new_e7.swap_up()

    assert isinstance(new_e7, Leader)
    assert new_e7.get_superior() is None
    assert new_e7.salary == 500000
    assert new_e7.position == "CEO"
    assert new_e7.get_department_name() == "Some Corp."
    new_subs = new_e7.get_direct_subordinates()
    assert new_subs[0].name == "Sarah"
    assert new_subs[1].name == "Sandra"
Exemple #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