Esempio n. 1
0
async def test_WAITING_FOR_REPLY() -> None:
    s = bcs.WAITING_FOR_REPLY("reqid")
    assert s.reply == None
    assert s.reqid == "reqid"

    r = await s.run(MockConnection(to_pop=None))
    assert r == "_transition_to_disconnected"
    assert s.reply is None

    m = MockMessage()
    r = await s.run(MockConnection(to_pop=m))
    assert r[0] == "_transition"
    assert isinstance(r[1], bcs.CONNECTED_AFTER_ACK)
    assert s.reply is m

    s._reqid = "nomatch"
    r = await s.run(MockConnection(to_pop=m))
    assert r == "_next"
def test_WAITING_FOR_REPLY():
    s = bcs.WAITING_FOR_REPLY("reqid")
    assert s.reply == None
    assert s.reqid == "reqid"

    r = s.run(_MockConnection(to_pop=None))
    assert r.result() == "_transition_to_disconnected"
    assert s.reply is None

    m = _MockMessage()
    r = s.run(_MockConnection(to_pop=m))
    res = r.result()
    assert res[0] == "_transition"
    assert isinstance(res[1], bcs.CONNECTED_AFTER_ACK)
    assert s.reply is m

    s._reqid = "nomatch"
    r = s.run(_MockConnection(to_pop=m))
    assert r.result() == "_next"
Esempio n. 3
0
async def test_WAITING_FOR_REPLY() -> None:
    s = bcs.WAITING_FOR_REPLY("reqid")
    assert s.reply is None
    assert s.reqid == "reqid"

    c = MockConnection()
    await s.run(c)
    assert c.state == "_transition_to_disconnected"
    assert s.reply is None

    m = MockMessage()
    c = MockConnection(to_pop=m)
    await s.run(c)
    assert c.state[0] == "_transition"
    assert isinstance(c.state[1], bcs.CONNECTED_AFTER_ACK)
    assert s.reply is m

    s._reqid = "nomatch"
    c = MockConnection(to_pop=m)
    await s.run(c)
    assert c.state == "_next"