Index: suite_leahi/tst_blood_set_auto/test.py =================================================================== diff -u -rb3ed49151211c950665280877e609144bc79d477 -r625ff1b3c488dd364588e4ea6143dc8e63c2bb74 --- suite_leahi/tst_blood_set_auto/test.py (.../test.py) (revision b3ed49151211c950665280877e609144bc79d477) +++ suite_leahi/tst_blood_set_auto/test.py (.../test.py) (revision 625ff1b3c488dd364588e4ea6143dc8e63c2bb74) @@ -23,40 +23,34 @@ from leahi_dialin.protocols import CAN from leahi_dialin.utils import conversions -td_simulator = TD_Messaging() +td_simulator = TD_Messaging() +can_interface = td_simulator.can_interface +bloodSetAutoLoad = None +bloodSetAutoEject = None # handler for messages from UI to FW -def handle_blood_set_auto_load_request(message, timestamp=0.0): +def handle_blood_set_auto_load_request( message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ - message = message["message"] - index = MsgFieldPositions.START_POS_FIELD_1 - state, index = conversions.bytearray_to_integer(message, index) global bloodSetAutoLoad - bloodSetAutoLoad = str(state) + bloodSetAutoLoad = True # handler for messages from UI to FW -def handle_blood_set_auto_eject_request(message, timestamp=0.0): +def handle_blood_set_auto_eject_request( message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ - message = message["message"] - index = MsgFieldPositions.START_POS_FIELD_1 - state, index = conversions.bytearray_to_integer(message, index) global bloodSetAutoEject - bloodSetAutoEject = str(state) + bloodSetAutoEject = True + def main(): utils.tstStart(__file__) test.startSection("Blood Set Auto Load and Eject") - td_interface = TD_Messaging() - can_interface = td_interface.can_interface - global bloodSetAutoLoad - global bloodSetAutoEject - + # handle bloodSetAutoLoad sent messages from UI if can_interface is not None: channel_id = CAN.DenaliChannels.ui_to_td_ch_id @@ -70,7 +64,7 @@ channel_id = CAN.DenaliChannels.ui_to_td_ch_id message_id = MsgIds.MSG_ID_UI_ADJUST_DISPOSABLES_REMOVAL_CONFIRM_REQUEST.value can_interface.register_receiving_publication_function( - channel_id, message_id, handle_blood_set_auto_load_request + channel_id, message_id, handle_blood_set_auto_eject_request ) application_init.reset_system_setting("AdvancedMode") @@ -85,10 +79,10 @@ mouseClick(waitForObject(utility.findChildByText(pre_treatment, config.NEXT), 3000)) mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.AUTO_LOAD)) + test.verify( - waitFor("'bloodSetAutoLoad == 1'", 5000), "Testing UI -> TD message Auto Load" + waitFor(lambda: bloodSetAutoLoad == True, 10000), "Testing UI -> TD message Auto Load" ) - td_simulator.td_blood_set_auto_load_response(1) auto_load_reject_notification = utility.findChildByText( pre_treatment, config.BLOOD_SET_AUTO_LOAD_REJECTION @@ -188,8 +182,7 @@ waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) ) - mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.NEXT)) - mouseClick(utility.setObjectText(names.o_preTreatmentStack_Text, config.START)) + mouseClick(waitForObject(utility.setObjectText(names.o_preTreatmentStack_Text, config.START), 3000)) td_simulator.td_operation_mode(TDOpModes.MODE_TREA.value, 0) td_simulator.td_tx_state( @@ -202,7 +195,7 @@ ) mouseClick(waitForObject(utility.findChildByText(post_treatment, config.AUTO_EJECT), 3000)) test.verify( - waitFor("'bloodSetAutoEject == 1'", 5000), "Testing UI -> TD message Auto Eject" + waitFor(lambda: bloodSetAutoEject == True, 10000), "Testing UI -> TD message Auto Eject" ) td_simulator.td_blood_set_auto_eject_response(1)