Ejemplo n.º 1
0
def test_insert_recvs():
    jobson = {1: 'a', 2: 'b', 3: 'a'}
    prec = {3: (1, 2)}
    aorder = [Event(1, 0, 2), Event(3, 3, 5)]
    result = insert_recvs(aorder, jobson, prec)
    assert result[0] == aorder[0]
    assert result[-1] == aorder[-1]
    assert result[1].job == recv('b', 'a', 2, 3)
    assert jobson[recv('b', 'a', 2, 3)] == 'a'

    assert insert_recvs([], jobson, prec) == []
Ejemplo n.º 2
0
def test_insert_sendrecvs():
    prec = {3: (1, 2),
            2: (1,)}
    succ = reverse_dict(prec)
    jobson = {1: 'a', 2: 'b', 3: 'a'}
    orders = {'a': [Event(1, 0, 1), Event(3, 4, 8)],
              'b': [Event(2, 2, 3)]}

    neworders, newjobson = insert_sendrecvs(orders, jobson, succ)
    print neworders
    print newjobson
    assert Event(send('a', 'b', 1, 2), 1, 1) in neworders['a']
    assert Event(recv('a', 'b', 1, 2), 2, 2) in neworders['b']
    assert all(e in neworders[agent] for agent in orders
                                     for e in orders[agent])
Ejemplo n.º 3
0
def test_recvs():
    jobson = {1: 'a', 2: 'b', 3: 'a'}
    prec = {3: (1, 2)}
    assert recvs(1, jobson, prec) == []
    assert recvs(3, jobson, prec) == [recv('b', 'a', 2, 3)]