Index: suite_leahi/suite.conf =================================================================== diff -u -r5242b0f3bde261dff5670b39bdb263f084d237b6 -r8db28688e2a5c59581798955c6127a63addf100b --- suite_leahi/suite.conf (.../suite.conf) (revision 5242b0f3bde261dff5670b39bdb263f084d237b6) +++ suite_leahi/suite.conf (.../suite.conf) (revision 8db28688e2a5c59581798955c6127a63addf100b) @@ -1,6 +1,6 @@ AUT=leahi LANGUAGE=Python OBJECTMAPSTYLE=script -TEST_CASES=tst_solution_infusion tst_main_treatment tst_service_export_logs tst_device_settings_information_version tst_headerbar_information_popup tst_headerbar_wifi_indicator tst_device_settings_wifi tst_ultrafiltration tst_create_treatment tst_general_alarm_requirements_instruction tst_headerbar_prescription tst_heparin tst_pre_treatment_foundation tst_feature_options tst_end_of_treatment tst_service_institutional tst_settings_service tst_recirculate tst_blood_prime tst_headerbar_settings_diagnostics_popup tst_isolated_uf tst_blood_set_auto tst_patient_vitals tst_edit_parameters tst_rinseback +TEST_CASES=tst_fluid_bolus tst_main_treatment tst_service_export_logs tst_device_settings_information_version tst_headerbar_information_popup tst_headerbar_wifi_indicator tst_device_settings_wifi tst_ultrafiltration tst_create_treatment tst_general_alarm_requirements_instruction tst_headerbar_prescription tst_heparin tst_pre_treatment_foundation tst_feature_options tst_end_of_treatment tst_service_institutional tst_settings_service tst_recirculate tst_blood_prime tst_headerbar_settings_diagnostics_popup tst_isolated_uf tst_blood_set_auto tst_patient_vitals tst_edit_parameters tst_rinseback VERSION=3 WRAPPERS=Qt Index: suite_leahi/tst_fluid_bolus/test.py =================================================================== diff -u --- suite_leahi/tst_fluid_bolus/test.py (revision 0) +++ suite_leahi/tst_fluid_bolus/test.py (revision 8db28688e2a5c59581798955c6127a63addf100b) @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- + +# Pythons +import os +import can +from configuration import config, utility, application_init +from configuration.getrejectiontext import ScopedRejectionRepository + +# plugin specific +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.protocols import CAN +from leahi_dialin.utils import conversions + +from leahi_dialin.common.td_defs import TDOpModes, TDTreatmentStates +from leahi_dialin.common.ui_defs import TXStates + +# td Simulator +from leahi_dialin.ui.td_messaging import TD_Messaging + +import names + +salineBolusStartState = None + +def main(): + td_interface = TD_Messaging() + can_interface = td_interface.can_interface + global salineBolusStartState + + # handle sent messages from UI + if can_interface is not None: + channel_id = CAN.CanChannels.ui_to_td_ch_id + message_id = MsgIds.MSG_ID_UI_SOLUTION_INFUSION_REQUEST.value + can_interface.register_receiving_publication_function(channel_id, + message_id, + handle_solution_infusion_request) + + + startApplication(utility.aut("-q")) + test.log("Starting leahi") + + td_interface.td_operation_mode( TDOpModes.MODE_STAN.value, 0 ) + + # verify Standby screen + test.verify(waitForObjectExists(names.o_standByScreen_MainHome), "In Standby") + td_interface.td_operation_mode( TDOpModes.MODE_TREA.value, 0 ) + td_interface.td_tx_state( + TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 + ) + + # verify main treatment screen + test.verify(waitForObjectExists(names.mainTreatmentScreen), "In Main Treatment") + + # verify saline text + salineTextObj = waitForObject(names.salineDeliveredText) + test.compare(salineTextObj.text, config.TOTAL_FLUID_DELIVERED, "Testing 'Total Saline Delivered' text") + + verify_start_bolus_button_state(config.DISABLED, "Comparison of Start Bolus Button Disabled State") + + # enable start bolus button + td_interface.td_saline( + 0, # target_volume + 0, # bolus_volume + 0, # cumulative_volume + 1 # bolus_permitted + ) + + verify_start_bolus_button_state(config.ENABLED, "Comparison of Start Bolus Button Enabled State") + + # verify send start bolus req message + mouseClick(waitForObject(names.startFluidButton)) + test.verify(waitFor(lambda: salineBolusStartState == 1, 5000), "Testing UI -> TD message start bolus") + + # change state to in progress + td_interface.td_tx_state( + TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + TXStates.SALINE_BOLUS_STATE_IN_PROGRESS , # saline in progess + 0 + ) + + # verify isStarted property binding to vTDTreatmentStates.sbRunning + treatmentSaline = waitForObject(names.treatmentSaline) + test.compare(treatmentSaline.isStarted, True, "Testing vTDTreatmentStates.sbRunning") + + # verify text + test.compare(salineTextObj.text, config.DELIVERING_FLUID, "Testing Saline Description text") + + # verify saline data + bolusValueInTest = 75 + td_interface.td_saline( + 100 , # target_volume + bolusValueInTest, # bolus_volume + 150 , # cumulative_volume + 1 # bolus_permitted + ) + + # verify saline text + currentBolusTextObj = waitForObject(names.currentBolusVolume) + test.compare(currentBolusTextObj.text, str(bolusValueInTest), "Testing current bolus value text") + + # verify progress bar + progressBarObj = waitForObject(names.salineProgressBar) + test.compare(progressBarObj.value, bolusValueInTest, "Testing progress bar current bolus value") + + # verify send stop bolus req message + mouseClick(waitForObject(names.startFluidButton)) + test.verify(waitFor(lambda: salineBolusStartState == 0, 5000), "Testing UI -> TD message stop bolus") + + # change state to idle + td_interface.td_tx_state( + TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + TXStates.SALINE_BOLUS_STATE_IDLE , # saline in idle + 0 + ) + + # verify progress bar set off + test.compare(progressBarObj.value, 0, "Testing progress bar bolus off") + + mouseClick(waitForObject(names.o_treatmentHome_editButton_IconButton_2)) + # Comparison of Rejection Reasons + conf_path = application_init.configuration_folder_path() + "Alarms/Rejections.conf" + repo = ScopedRejectionRepository(path=conf_path) + for rejection_reason in range(1, 60): + td_interface.cmd_send_general_response(message_id =MsgIds.MSG_ID_TD_BOLUS_VOLUME_CHANGE_RESPONSE.value, + reason=rejection_reason, + accepted=0, + ) + REJECT_TEXT = repo.get(str(rejection_reason), "Title") + bolus_popup_notification = utility.get_object_from_names( + names.o_notification_bar + ) + + bolus_popup_notification_text = str(bolus_popup_notification.text) + test.compare( + bolus_popup_notification_text, + "[" + str(rejection_reason) + "] " + REJECT_TEXT, + f"Rejection reason number comparison for reason {rejection_reason}", + ) + + +# handler for messages from UI to FW +def handle_solution_infusion_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 salineBolusStartState + salineBolusStartState = state + +# verify start bolus button enabled or disabled state +def verify_start_bolus_button_state(expected_state, message): + """Helper function to verify the enabled/disabled state using test.compare.""" + + start_bolus_button = findObject(names.startFluidButton) + current_state = start_bolus_button.enabled + test.compare(current_state, expected_state, message) + \ No newline at end of file