def test_reply_none(self): reply = controller.Reply(45) reply.handle() reply.send(None) reply.take() reply.commit() assert reply.q.get() is None
def test_kill(self): reply = controller.Reply(43) reply.handle() reply.kill() reply.take() reply.commit() assert reply.q.get() == Kill
def test_ack(self): reply = controller.Reply(44) reply.handle() reply.ack() reply.take() reply.commit() assert reply.q.get() == 44
def test_double_send(self): reply = controller.Reply(47) reply.send(1) with pytest.raises(ControlException): reply.send(2) reply.take() reply.commit()
def test_del(self): reply = controller.Reply(47) with pytest.raises(ControlException): reply.__del__() reply.ack() reply.take() reply.commit()
def test_commit_no_reply(self): reply = controller.Reply(46) reply.take() with pytest.raises(ControlException): reply.commit() reply.ack() reply.commit()
async def test_simple(self): reply = controller.Reply(42) assert reply.state == "start" reply.take() assert reply.state == "taken" assert not reply.done.is_set() reply.commit() assert reply.state == "committed" assert await asyncio.wait_for(reply.done.wait(), 1)
def test_simple(self): reply = controller.Reply(42) assert reply.state == "start" reply.send("foo") assert reply.value == "foo" reply.take() assert reply.state == "taken" with pytest.raises(queue.Empty): reply.q.get_nowait() reply.commit() assert reply.state == "committed" assert reply.q.get() == "foo"
def test_state_transitions(self): states = {"start", "taken", "committed"} accept = { "take": {"start"}, "commit": {"taken"}, "ack": {"start", "taken"}, } for fn, ok in accept.items(): for state in states: r = controller.Reply(48) r._state = state if fn == "commit": r.value = 49 if state in ok: getattr(r, fn)() else: with pytest.raises(ControlException): getattr(r, fn)() r._state = "committed" # hide warnings on deletion
def test_simple(self): reply = controller.Reply(42) assert not reply.acked reply.send("foo") assert reply.acked assert reply.q.get() == "foo"
def test_reply_none(self): reply = controller.Reply(42) reply.send(None) assert reply.q.get() is None
def test_default(self): reply = controller.Reply(42) reply.ack() assert reply.q.get() == 42