Index: suite_leahi/shared/scripts/configuration/config.py =================================================================== diff -u -r5a31e21e36f2652df87477d61a8b9f43f2bc89d2 -rb122be36d823c52ae3ef21b122c97ed9f9f165a9 --- suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision 5a31e21e36f2652df87477d61a8b9f43f2bc89d2) +++ suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision b122be36d823c52ae3ef21b122c97ed9f9f165a9) @@ -219,3 +219,10 @@ REJECTION_REASON = "[1] Request is not allowed in the current operating mode" END_TREATMENT = "End Treatment" +#Post-Treatment Foundation +END_TREATMENT = "End Treatment" +CONTINUE = "Continue" +CONFIGURATIONS_PATH = "Public/luis/config/configurations/" +SKIP = "Skip" + + Index: suite_leahi/tst_post-treatment_foundation/test.py =================================================================== diff -u --- suite_leahi/tst_post-treatment_foundation/test.py (revision 0) +++ suite_leahi/tst_post-treatment_foundation/test.py (revision b122be36d823c52ae3ef21b122c97ed9f9f165a9) @@ -0,0 +1,148 @@ +# Subject/Title: LDT-3946 Post-Treatment - SW - 02 - Foundation - Q&R +# +# Functionalities: Testing of Post-Treatment Foundation +# +# Steps: +# 1 Handle patientDisconnectConfirmRequest and bloodSetAutoEject sent messages from UI +# 2 Start Leahi Application, simulate TD standby mode and simulate TD Post Mode +# and Navigate to Post-Treatment Screen and Compare Page Title text +# 3 Click on Continue button in UI and Verify FW receives the request, Test Rejection Reason and Navigate to next screen +# 4 Click on Auto Eject Button in UI And Verify FW receives the request, Test Rejection Reason +# 5 Click on Continue button to Navigate to next screen +# 6 Click on Skip button + +import names +import re +from configuration import config, utility, navigation, application_init +from leahi_dialin.ui import utils +from leahi_dialin.ui.td_messaging import TD_Messaging +from leahi_dialin.common.td_defs import TDOpModes +from leahi_dialin.common.msg_defs import MsgIds +from leahi_dialin.protocols import CAN +from configuration.getrejectiontext import ScopedRejectionRepository +from pathlib import Path + +td_simulator = TD_Messaging() +can_interface = td_simulator.can_interface +patientDisconnectConfirmRequest = None +bloodSetAutoEject = None + + +def handle_patient_disconnect_confirm_request(message, timestamp=0.0): + """ + Called when the user requests to firmware from UI + @return: None + """ + global patientDisconnectConfirmRequest + patientDisconnectConfirmRequest = True + + +# handler for messages from UI to FW +def handle_blood_set_auto_eject_request(message, timestamp=0.0): + """ + Called when the user requests to firmware from UI + @return: None + """ + global bloodSetAutoEject + bloodSetAutoEject = True + + +def main(): + utils.tstStart(__file__) + test.startSection("Post-Treatment Foundation") + + if can_interface is None: + test.fail("CAN Interface is not available. Stopping tests.") + return + + channel_id = CAN.CanChannels.ui_to_td_ch_id + + # Register Patient Disconnect Confirm Request + message_id = MsgIds.MSG_ID_UI_ADJUST_PATIENT_DISCONNECT_CONFIRM_REQUEST.value + can_interface.register_receiving_publication_function( + channel_id, message_id, handle_patient_disconnect_confirm_request + ) + # Register Blood Set Auto Eject Request + 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_eject_request + ) + + startApplication(utility.aut("-q")) + + td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value) + td_simulator.td_operation_mode(TDOpModes.MODE_POST.value) + headerbar_container = utility.get_object_from_names(names.o_headerBar_HeaderBar) + headerbar_title = utility.findChildByText(headerbar_container, config.END_TREATMENT) + test.compare( + headerbar_title.text, + config.END_TREATMENT, + "{} screen is displayed and Comparison of End Treatment Screen Title text".format( + config.END_TREATMENT + ), + ) + + conf_path = Path.home() / config.CONFIGURATIONS_PATH / "Alarms/Rejections.conf" + repo = ScopedRejectionRepository(path=conf_path) + + post_treatment = utility.get_object_from_names( + names.o_PostTreatmentStack_PostTreatmentStack + ) + mouseClick( + waitForObject(utility.findChildByText(post_treatment, config.CONTINUE), 3000) + ) + test.verify( + waitFor(lambda: patientDisconnectConfirmRequest == True, 5000), + "Testing UI -> TD message Patient Disconnect Confirm Request", + ) + + REJECT_TEXT = repo.get("1", "Title") + td_simulator.td_patient_disconnect_confirm_response(0, 1) + patient_disconnect_notification = utility.findChildByText( + post_treatment, "[1] " + REJECT_TEXT + ) + patient_disconnect_notification_text = str(patient_disconnect_notification.text) + digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", patient_disconnect_notification_text) + + if digit: + digit_int = int(float(digit)) + test.compare(1, digit_int, f"Rejection reason number comparison for reason {1}") + test.log(f"Rejection reason text is {patient_disconnect_notification_text}") + + td_simulator.td_patient_disconnect_confirm_response(1, 0) + + mouseClick( + waitForObject(utility.findChildByText(post_treatment, config.CONTINUE), 3000) + ) + mouseClick( + waitForObject(utility.findChildByText(post_treatment, config.AUTO_EJECT), 3000) + ) + test.verify( + waitFor(lambda: bloodSetAutoEject == True, 10000), + "Testing UI -> TD message Auto Eject", + ) + + td_simulator.td_blood_set_auto_eject_response(0, 1) + REJECT_TEXT = repo.get("1", "Title") + auto_eject_reject_notification = utility.findChildByText( + post_treatment, "[1] " + REJECT_TEXT + ) + auto_eject_reject_notification_text = str(auto_eject_reject_notification.text) + digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", auto_eject_reject_notification_text) + + if digit: + digit_int = int(float(digit)) + test.compare(1, digit_int, f"Rejection reason number comparison for reason {1}") + test.log(f"Rejection reason text is {auto_eject_reject_notification_text}") + + td_simulator.td_blood_set_auto_eject_response(1, 0) + + mouseClick( + waitForObject(utility.findChildByText(post_treatment, config.CONTINUE), 3000) + ) + mouseClick( + waitForObject(utility.findChildByText(post_treatment, config.SKIP), 3000) + ) + + test.endSection() + utils.tstDone()