def test_wrong_handler(self, test_db, test_entry_dev1_ctrl): handler = Handler.ModemDbSearch(test_db) handler._PLM_sent = True handler._PLM_ACK = True msg = Msg.OutAllLinkCancel() ret = handler.msg_received(test_db.device.protocol, msg) assert ret == Msg.UNKNOWN
def test_nack(self, test_db, test_entry_dev1_ctrl): handler = Handler.ModemDbSearch(test_db) db_flags = Msg.DbFlags( in_use=True, is_controller=test_entry_dev1_ctrl.is_controller, is_last_rec=False) msg = Msg.OutAllLinkUpdate(Msg.OutAllLinkUpdate.Cmd.EXISTS, db_flags, test_entry_dev1_ctrl.group, test_entry_dev1_ctrl.addr, data=None, is_ack=False) ret = handler.msg_received(test_db.device.protocol, msg) assert ret == Msg.FINISHED
def test_entry_received(self, test_db, test_entry_dev1_ctrl): handler = Handler.ModemDbSearch(test_db) db_flags = Msg.DbFlags( in_use=True, is_controller=test_entry_dev1_ctrl.is_controller, is_last_rec=False) msg = Msg.InpAllLinkRec(db_flags, test_entry_dev1_ctrl.group, test_entry_dev1_ctrl.addr, test_entry_dev1_ctrl.data) ret = handler.msg_received(test_db.device.protocol, msg) assert ret == Msg.FINISHED assert len(test_db) == 1 assert test_db.entries[0] == test_entry_dev1_ctrl sent = test_db.device.protocol.sent assert len(sent) == 1 assert sent[0].msg.cmd == Msg.OutAllLinkUpdate.Cmd.SEARCH assert sent[0].msg.group == test_entry_dev1_ctrl.group assert sent[0].msg.addr == test_entry_dev1_ctrl.addr
def test_entry_not_used(self, test_db, test_entry_dev1_ctrl): # I don't think this is possible, but we have the code, so test for it handler = Handler.ModemDbSearch(test_db) db_flags = Msg.DbFlags( in_use=False, is_controller=test_entry_dev1_ctrl.is_controller, is_last_rec=False) msg = Msg.InpAllLinkRec(db_flags, test_entry_dev1_ctrl.group, test_entry_dev1_ctrl.addr, test_entry_dev1_ctrl.data) ret = handler.msg_received(test_db.device.protocol, msg) assert ret == Msg.FINISHED assert len(test_db) == 0 sent = test_db.device.protocol.sent assert len(sent) == 1 assert sent[0].msg.cmd == Msg.OutAllLinkUpdate.Cmd.SEARCH assert sent[0].msg.group == test_entry_dev1_ctrl.group assert sent[0].msg.addr == test_entry_dev1_ctrl.addr
def test_plm_sent(self, test_db, tmpdir): db_flags = Msg.DbFlags(in_use=True, is_controller=False, is_last_rec=False) handler = Handler.ModemDbSearch(test_db) assert not handler._PLM_sent #Try a message prior to sent msg = Msg.OutAllLinkUpdate(Msg.OutAllLinkUpdate.Cmd.EXISTS, db_flags, 0x01, 0x01, data=None, is_ack=True) ret = handler.msg_received(test_db.device.protocol, msg) assert ret == Msg.UNKNOWN # Signal Sent handler.sending_message(msg) assert handler._PLM_sent #Try a message after sent ret = handler.msg_received(test_db.device.protocol, msg) assert ret == Msg.CONTINUE