# -*- coding: utf-8 -*-" import names from dialin.squish import utils from dialin.ui.hd_simulator import HDSimulator from dialin.common.msg_defs import RequestRejectReasons from time import sleep def skip_create_treatment(hd_simulator: HDSimulator): rejections = [ RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # requestValid RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # bloodFlowRate RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # dialysateFlowRate RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # duration RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # heparinStopTime RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # salineBolus RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # acidConcentrate RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # bicarbonateConcentrate RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # dialyzerType RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # bloodPressureMeasureInterval RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # rinsebackFlowRate RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # arterialPressureLimitLow RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # arterialPressureLimitHigh RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # venousPressureLimitLow RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # venousPressureLimitHigh RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # heparinDispensingRate RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # heparinBolusVolume RequestRejectReasons.REQUEST_REJECT_REASON_NONE, # dialysateTemp ] hd_simulator.cmd_send_treatment_parameter_validation_response(rejections) def test_confirm_priming_begin(hd_simulator: HDSimulator): """ Simulates the HD actions during confirm priming and begin (pre-treatment). @param hd_simulator: the HDSimulator object @return: None """ # bypass selecting parameters and their validation (see tst_CreateTreatment) hd_simulator.cmd_send_start_treatment_response(1, 0) skip_create_treatment(hd_simulator) test.compare(waitForObjectExists(names.o_confirm_treatment_flickable).visible, True, "Found confirm treatment flickable") flick(waitForObject(names.o_confirm_treatment_flickable), 0, 700) mouseClick(waitForObject(names.o_create_treatment_confirm)) # wait for priming simulation to complete sleep(7) # advance to start the treatment test.compare(waitForObjectExists(names.o_priming_flickable).visible, True, "Found priming flickable") flick(waitForObject(names.o_priming_flickable), 0, 123) test.compare(waitForObjectExists(names.o_priming_continue_button).visible, True, "Found priming continue button") mouseClick(waitForObject(names.o_priming_continue_button)) sleep(0.1) test.compare(waitForObjectExists(names.o_treatment_begin_back_button).visible, True, "Found treatment begin back button") mouseClick(waitForObject(names.o_treatment_begin_back_button)) sleep(0.1) test.compare(waitForObjectExists(names.o_priming_back_button).visible, True, "Found priming back button") mouseClick(waitForObject(names.o_priming_back_button)) sleep(0.1) test.compare(waitForObjectExists(names.o_create_treatment_confirm_back_button).visible, True, "Found create treatment confirm back button") mouseClick(waitForObject(names.o_create_treatment_confirm_back_button)) sleep(0.1) test.compare(waitForObjectExists(names.o_create_treatment_back_button).visible, True, "Found create treatment back button") mouseClick(waitForObject(names.o_create_treatment_back_button)) sleep(0.1) mouseClick(waitForObject(names.o_create_treatment_button)) skip_create_treatment(hd_simulator) sleep(0.1) test.compare(waitForObjectExists(names.o_create_treatment_confirm).visible, True, "Found treatment confirm button") mouseClick(waitForObject(names.o_create_treatment_confirm)) sleep(7) test.compare(waitForObjectExists(names.o_priming_continue_button).visible, True, "Found priming continue button") mouseClick(waitForObject(names.o_priming_continue_button)) sleep(0.1) test_ultrafiltration_slider(hd_simulator) sleep(0.1) test.compare(waitForObjectExists(names.o_treatment_begin_start_button).visible, True, "Found treatment start button") mouseClick(waitForObject(names.o_treatment_begin_start_button)) sleep(2) mouseClick(waitForObject(names.o_treatmentStart_back)) mouseClick(waitForObjectExists(names.o_mainMenu_settings)) mouseClick(waitForObject(names.o_settings_end_treatment)) sleep(3) def test_ultrafiltration_slider(hd_simulator: HDSimulator): """ Tests the ultrafiltration slider @param hd_siulator: The HDSimulator object @return: None """ slider_name = "_ultrafiltration" slider_object_name = slider_name + "Slider" test.log("Slider Under Test", slider_object_name) slider_selected_value_object_name = slider_name + "Value" slider_object = {"container": names.o_treatment_begin_container, "objectName": slider_object_name, "type": "Slider" } selected_value_object = { "container": names.o_treatment_begin_container, "objectName": slider_selected_value_object_name, "type": "Text" } test.compare(waitForObjectExists(selected_value_object).visible, True) mouseClick(waitForObject(slider_object), -40, 0, Qt.LeftButton) sleep(0.01) test.compare(waitForObjectExists(selected_value_object).text, "{0} {1}".format(0, "mL")) mouseClick(waitForObject(slider_object), waitForObjectExists(slider_object).width, 0, Qt.LeftButton) sleep(0.01) test.compare(waitForObjectExists(selected_value_object).visible, True) test.compare(waitForObjectExists(selected_value_object).text, "{0} {1}".format(8, "mL")) def main(): utils.tstStart(__file__) startApplication(names.AUT_NAME + " -q") hd_simulator = HDSimulator() test_confirm_priming_begin(hd_simulator) utils.tstDone()