# -*- coding: utf-8 -*- ## # Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. # copyright # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # file tst_In_treatment # date 2020/02/11 # author Joseph Varghese # # NOTE: # This test contradicts verification of saline bolus in In-treatment section of Application import names from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from dialin.common.ui_defs import TXStates as txStates from dialin.common.msg_defs import RequestRejectReasons as rejectReason from configuration import config, utility #testing options for main treatment saline SALINE_BOLUS_TARGET = [0, 1, 150, 155, 299, 300] #Boundary Value Analysis hd_simulator = HDSimulator() def get_unit(): """ Method to get unit of saline values """ return str(waitForObjectExists(names.o_treatmentStart_SalineSection).unit) def verification_of_target_value(expected_target_value): """ Method to verify target value on saline section @param expected_target_value: (int) expected target value on saline section """ test.compare(waitForObjectExists(names.o_treatmentStart_SalineSection).valueTarget , float(expected_target_value), "Target value verified") test.compare(waitForObjectExists(names.o_treatmentHome_mL_Text).text , get_unit(), "Target unit verified" ) def verification_of_cumulative_value(expected_cumulative_value): """ Method to verify cumulative value on saline section @param expected_cumulative_value: (int) expected cumulative value on saline section """ test.compare(waitForObjectExists(names.o_treatmentHome_cumalative_value).text , expected_cumulative_value, "cumulative value verified") test.compare(waitForObjectExists(names.o_treatmentHome_cumalative_unit).text , config.SALINE_UNIT, "cumulative unit verified" ) def verification_of_delivered_value(expected_delivered_value): """ Method to verify delivered value on saline section @param expected_delivered_valuee: (int) expected delivered value on saline section """ test.compare(waitForObjectExists(names.o_treatmentHome_delivered_value).text , expected_delivered_value, "delivered value verified") test.compare(waitForObjectExists(names.o_treatmentHome_delivered_unit).text , config.SALINE_UNIT, "delivered unit verified" ) test.compare((waitForObjectExists(names.o_treatmentHome_fluidProgressBar_ProgressBar).enabled), True, "Fluid Progress Bar is enable") def goto_screen_contains_treatment_saline_bolus_data(): """ Method to verify saline bolus data. @param : none @return: none """ test.compare(str(waitForObjectExists(names.o_treatmentStart_SalineSection).buttonText), "START BOLUS", "Saline button text is visible") test.compare(str(waitForObjectExists(names.o_treatmentStart_SalineSection).title ), "SALINE BOLUS", "Saline button title is visible") test.compare( waitForObjectExists(names.o_treatmentStart_SalineSection).visible , True, "Saline button is visible") utils.waitForGUI(0.5) def test_ultrafiltration_touchable(enabled_status): """ Method to verify uf touchable area state @param : enabled_status: (bool) True/False -> based on visibility @return: none """ test.compare(waitForObjectExists(names.o_treatmentHome_ultrafiltrationTouchArea_TreatmentUltrafiltration).isTouchable, enabled_status,\ "uf touchable area is visible") def test_state(accept_status, button_text, target, saline_states): """ Method to verify rejection message and transition state of saline bolus parameter. @param accept_status: (int) boolean accept/reject response @param button_text: (str) "START"/"STOP" based on button text. @param target: (int) saline bolus Target volume @param saline_states: (int) saline bolus transition State @return: none """ rejection_reason = 0 # when rejected reason set 16 -> saline bolus in progress if (not accept_status): rejection_reason = rejectReason.REQUEST_REJECT_REASON_SALINE_BOLUS_IN_PROGRESS.value hd_simulator.cmd_set_saline_bolus_response(accepted = accept_status, reason = rejection_reason, target = target) if (not accept_status): test.compare(waitForObjectExists(utility.rejection_msg(config.REJECTION_REASON[rejection_reason])).text, config.REJECTION_REASON[rejection_reason], \ "expected rejection {msg} displayed".format(msg=config.REJECTION_REASON[rejection_reason])) #set saline transition state. hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=saline_states, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state= 0, dialysis_state=0) test.compare(str(waitForObjectExists(names.o_treatmentStart_SalineSection).buttonText), "{} BOLUS".format(button_text)) verification_of_target_value(expected_target_value = target) def test_rejection_message_on_saline_bolus(accept_status, target, saline_states): """ verification of rejection messages on saline bolus. @param accept_status: (int) boolean accept/reject response @param target: (int) saline bolus Target volume @param saline_states: (int) saline bolus transition State @return: none """ test.startSection("verification of rejection messages on saline bolus") for rejection in range(1, config.NUM_OF_REQUEST_REJECT_REASONS): hd_simulator.cmd_set_saline_bolus_response(accepted = accept_status, reason = rejection, target = target) rejection_message = waitForObjectExists(utility.rejection_msg(config.REJECTION_REASON[rejection])) test.compare(rejection_message.text, config.REJECTION_REASON[rejection], "expected rejection {msg} displayed".format(msg=config.REJECTION_REASON[rejection])) test.endSection() def test_saline_values(): """ verification of target value, cumulative value and delivered value from dialysis state. @param: none @return: none """ test.startSection("verification of saline parameter values on main treatment screen") #FIXME: execution time is more, so used specified saline target value for verification. for target_value in SALINE_BOLUS_TARGET: for delivered_value, cumulative_value in config.SALINE_BOLUS_VALUES.items(): hd_simulator.cmd_set_treatment_saline_bolus_data(target = target_value, cumulative = cumulative_value, delivered = delivered_value) test.log("verification of saline values from dialysis state for target value :" + str(target_value)+\ " cumulative value :" +str(cumulative_value)+" and delivered value :"+ str(delivered_value)) verification_of_target_value(expected_target_value = format(target_value, '.1f')) verification_of_delivered_value(expected_delivered_value = format(delivered_value, '.0f')) verification_of_cumulative_value(expected_cumulative_value = format(cumulative_value, '.0f')) test.endSection() def test_saline_stage(): """ verification of saline states and rejection message on saline bolus section. @param : none @return: none """ test.startSection("verification of saline stages on main treatment screen") saline_bolus_target = len(SALINE_BOLUS_TARGET)-1 saline_target_value = SALINE_BOLUS_TARGET[saline_bolus_target] #verification of total rejection message on saline bolus touch section. test_rejection_message_on_saline_bolus(True, saline_target_value, txStates.SALINE_BOLUS_STATE_IDLE) # Initial Idle -> Idle/START/UF_True goto_screen_contains_treatment_saline_bolus_data() test_ultrafiltration_touchable(True) # Initial Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True) # retry Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True) # Still Idle => Running => Accepted -> Running/STOP/UF_False test_state(True , "STOP" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) # Now Running => Idle => Rejected -> Running/STOP/UF_False test_state(True, "STOP" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) # Retry Running => Idle => Rejected -> Running/STOP/UF_False test_state(False, "STOP" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) # Still Running => Idle => Accepted -> Idle/START/UF_True test_state(True , "START" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True) # Now Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True) # Retry Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True) # Still Idle => Running => Accepted -> Running/STOP/UF_False test_state(True , "STOP" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) # Still Idle => Running => Accepted -> Running/STOP/UF_False test_state(True , "STOP" ,saline_target_value, txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) test.endSection() def test_saline_types(): test.startSection("verification of saline parameter states on main treatment screen") hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state= 0, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state= 0, dialysis_state=0 ) mouseClick(waitForObject(names.o_treatmentHome_startFluidButton_TouchRect)) test.compare((waitForObjectExists(names.o_treatmentHome_startFluidButton_TouchRect).enabled), True, "START BOLUS button is enable") test.compare((waitForObjectExists(names.o_treatmentHome_START_BOLUS_Text).enabled), True, "Start Bolus text is enable") hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state= 1, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state= 0, dialysis_state=0 ) test.compare((waitForObjectExists(names.o_treatmentHome_startFluidButton_TouchRect).enabled), False, "START BOLUS button is not enable") test.compare((waitForObjectExists(names.o_treatmentHome_START_BOLUS_Text).enabled), False, "Start Bolus text is not enable") test.compare((waitForObjectExists(names.o_treatmentHome_START_BOLUS_Text).enabled), False, "Start Bolus text is not enable") test.compare((waitForObjectExists(names.o_treatmentHome_image_Image).visible), True, "Pause Image is Visible") test.compare(str(waitForObjectExists(names.o_treatmentHome_Treatment_Paused_Text).text), "Treatment Paused", "Treatment Paused text is visible") hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state= 2, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state= 0, dialysis_state=0 ) mouseClick(waitForObjectExists(names.o_treatmentHome_stop_bolus_Text)) mouseClick(waitForObject(names.o_treatmentHome_Treatment_Paused_Text)) test.compare((waitForObjectExists(names.o_treatmentHome_image_Image).visible), True, "Pause Image is Visible") test.compare(str(waitForObjectExists(names.o_treatmentHome_Treatment_Paused_Text).text), "Treatment Paused", "Treatment Paused text is visible") hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state= 3, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state= 0, dialysis_state=0 ) test.compare((waitForObjectExists(names.o_treatmentHome_startFluidButton_TouchRect).enabled), False, "START BOLUS button is not enable") test.compare((waitForObjectExists(names.o_treatmentHome_START_BOLUS_Text).enabled), False, "Start Bolus text is not enable") test.compare(str(waitForObjectExists(names.o_treatmentHome_Maximum_cumulative_saline_bolus_volume_delivered_Text).text), "Maximum cumulative saline bolus volume delivered", "Treatment Paused text is visible") test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) utils.waitForGUI(1) #navigate to dialysis state hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state=0, dialysis_state=0) #verification of target, cumulative and delivered value test_saline_values() #verification of saline stages test_saline_stage() #verification of saline types test_saline_types() utils.tstDone()