def test_assign_priority_via_insert():
    new_pq = PriorityQueue()
    for i in range(5):
        new_pq.insert(Job(priority=i + 1))
    new_pq.jobs[-1].time_created -= 100
    new_pq.insert(Job(priority=6))
    assert [job.priority for job in new_pq.jobs] == [8, 5, 6, 1, 4, 2]
def test_assign_priority_via_insert():
    new_pq = PriorityQueue()
    for i in range(5):
        new_pq.insert(Job(priority=i+1))
    new_pq.jobs[-1].time_created -= 100
    new_pq.insert(Job(priority=6))
    assert [job.priority for job in new_pq.jobs] == [8, 5, 6, 1, 4, 2]
def new_pq():
    pq = PriorityQueue()
    for index, value in enumerate([3, 3, 4, 9, 7, 7, 9, 9, 7, 8]):
        pq.insert(Job(priority=value))
        if not index % 3:
            pq._operations = 0
    pq._operations = 0
    return pq
def new_pq():
    pq = PriorityQueue()
    for index, value in enumerate([3,  3,  4,  9,  7,  7,  9,  9,  7,  8]):
        pq.insert(Job(priority=value))
        if not index % 3:
            pq._operations = 0
    pq._operations = 0
    return pq
def test_assign_priority_via_pop():
    new_pq = PriorityQueue()
    for _ in range(4):
        new_pq.insert(Job(priority=1))
    new_pq.jobs[3].time_created -= 100
    new_pq.pop()
    assert [job.priority for job in new_pq.jobs] == [6, 1, 1]
    new_pq.jobs[2].time_created -= 100
    new_pq._operations = 4
    new_pq.pop()
    assert [job.priority for job in new_pq.jobs] == [6, 1]
def test_assign_priority_via_pop():
    new_pq = PriorityQueue()
    for _ in range(4):
        new_pq.insert(Job(priority=1))
    new_pq.jobs[3].time_created -= 100
    new_pq.pop()
    assert [job.priority for job in new_pq.jobs] == [6,  1,  1]
    new_pq.jobs[2].time_created -= 100
    new_pq._operations = 4
    new_pq.pop()
    assert [job.priority for job in new_pq.jobs] == [6,  1]