# -*- coding: utf-8 -*-" import names from configuration import config, utility from dialin.ui import utils from dialin.common.msg_defs import RequestRejectReasons from dialin import HDSimulator from time import sleep slider_ranges = { "bloodFlowRateMin": 100, "bloodFlowRateMax": 500, "dialysateFlowRateMin": 100, "dialysateFlowRateMax": 600, "durationMin": 60, "durationMax": 480, "heparinDispensingRateMin": 0.1, "heparinDispensingRateMax": 1, "heparinBolusVolumeMin": 0.1, "heparinBolusVolumeMax": 2, "heparinStopTimeMin": 0, "heparinStopTimeMax": 480, "salineBolusMin": 100, "salineBolusMax": 300, "acidConcentrateOptions": [ "08-1251-1", "08-2251-0", "08-3251-9" ], "bicarbonateConcentrateOptions": [ "Dimesol - BC-201" ], "dialyzerTypeOptions": [ "Nipro Elisio-H 17", "Nipro Elisio-H 19", "Fresenius Optiflux F160NRe", "Fresenius Optiflux F180NRe" ], "dialysateTempMin": 35, "dialysateTempMax": 38, "arterialPressureLimitLowMin": -300, "arterialPressureLimitLowMax": 200, "arterialPressureLimitHighMin": -300, "arterialPressureLimitHighMax": 200, "venousPressureLimitLowMin": -100, "venousPressureLimitLowMax": 600, "venousPressureLimitHighMin": 100, "venousPressureLimitHighMax": 600, "bloodPressureMeasureIntervalMin": 15, "bloodPressureMeasureIntervalMax": 60, "rinsebackFlowRateMin": 50, "rinsebackFlowRateMax": 150 } def test_load_create_treatment(): """ Tests that we can load the create treatment page. @return: None """ createTreatmentButton = utility.get_object_from_names(names.o_create_treatment_button, "names.o_create_treatment_button object missing") if createTreatmentButton is not None: mouseClick(waitForObject(names.o_create_treatment_button)) utils.waitForGUI(0.5) test.compare(waitForObject(names.o_create_treatment_flickable).visible, True, "Create treatment page loads") def test_parameters_exist(): """ Tests that all treatment parameter components exist on the treatment parameters page. @return: None """ test.fail("TODO : test_parameters_exist() Need to update / remove the testcase to reflect new GUIs and navigation...return") return parameter_names = { "_bloodFlowRate": "SliderCreateTreatment", "_dialysateFlowRate": "SliderCreateTreatment", "_duration": "SliderCreateTreatment", "_heparinDispensingRate": "SliderCreateTreatment", "_heparinBolusVolume": "SliderCreateTreatment", "_heparinStopTime": "SliderCreateTreatment", "_salineBolus": "SliderCreateTreatment", "_acidConcentrateRect": "GridSelection", "_bicarbonateConcentrateRect": "GridSelection", "_dialyzerTypeRect": "GridSelection", "_dialysateTemperature": "SliderCreateTreatment", # "_arterialPressureLimits": "RangeSlider", # "_venousPressureLimits": "RangeSlider", "_bloodPressureMeasurementInterval": "SliderCreateTreatment", "_rinsebackFlowRate": "SliderCreateTreatment", "_continueButton": "TouchRect", } for parameter_name, type_name in parameter_names.items(): test.compare(waitForObjectExists({ "container": names.o_create_treatment_container, "objectName": parameter_name, "type": type_name }).visible, True, "Found " + parameter_name) def test_sliders(): """ Tests that all sliders have the correct min / max values and that the selected value is displayed correctly. @return: None """ test.fail("TODO : test_sliders() Need to update / remove the testcase to reflect new GUIs and navigation...return") return sliders = { "_bloodFlowRate": {"min": slider_ranges["bloodFlowRateMin"], "max": slider_ranges["bloodFlowRateMax"], "units": "mL/min" }, "_dialysateFlowRate": {"min": slider_ranges["dialysateFlowRateMin"], "max": slider_ranges["dialysateFlowRateMax"], "units": "mL/min" }, "_duration": {"min": slider_ranges["durationMin"], "max": slider_ranges["durationMax"], "units": "min" }, "_heparinDispensingRate": {"min": slider_ranges["heparinDispensingRateMin"], "max": slider_ranges["heparinDispensingRateMax"], "units": "mL/hr" }, "_heparinBolusVolume": {"min": slider_ranges["heparinBolusVolumeMin"], "max": slider_ranges["heparinBolusVolumeMax"], "units": "mL" }, "_heparinStopTime": {"min": slider_ranges["heparinStopTimeMin"], "max": slider_ranges["heparinStopTimeMax"], "units": "min" }, "_salineBolus": {"min": slider_ranges["salineBolusMin"], "max": slider_ranges["salineBolusMax"], "units": "mL" }, "_dialysateTemperature": {"min": slider_ranges["dialysateTempMin"], "max": slider_ranges["dialysateTempMax"], "units": "C" }, "_bloodPressureMeasurementInterval": {"min": slider_ranges["bloodPressureMeasureIntervalMin"], "max": slider_ranges["bloodPressureMeasureIntervalMax"], "units": "min" }, "_rinsebackFlowRate": {"min": slider_ranges["rinsebackFlowRateMin"], "max": slider_ranges["rinsebackFlowRateMax"], "units": "mL/min" }, } for slider_name, slider_info in sliders.items(): if slider_name == "_heparinStopTime": flick(waitForObject(names.o_create_treatment_flickable), 0, 300) sleep(1) if slider_name == "_salineBolus": flick(waitForObject(names.o_create_treatment_flickable), 0, 300) sleep(1) if slider_name == "_dialysateTemperature": flick(waitForObject(names.o_create_treatment_flickable), 0, 700) sleep(1) if slider_name == "_bloodPressureMeasurementInterval": flick(waitForObject(names.o_create_treatment_flickable), 0, 700) sleep(2) slider_object_name = slider_name + "Slider" slider_selected_value_object_name = slider_name + "Value" slider_object = {"container": names.o_create_treatment_container, "objectName": slider_object_name, "type": "Slider" } test.compare(waitForObject(slider_object).visible, True, "Found " + slider_object_name) mouseClick(waitForObject(slider_object), waitForObject(slider_object).width / 2, 5, Qt.LeftButton) mouseDrag(waitForObject(slider_object), waitForObject(slider_object).width / 2, 0, -waitForObject(slider_object).width / 2, 0, Qt.NoModifier, Qt.LeftButton) selected_value_object = { "container": names.o_create_treatment_container, "objectName": slider_selected_value_object_name, "type": "Text" } test.compare(waitForObject(selected_value_object).visible, True) test.compare(waitForObject(selected_value_object).text, "{0} {1}".format(slider_info["min"], slider_info["units"])) mouseClick(waitForObject(slider_object), waitForObject(slider_object).width - 2, 0, Qt.LeftButton) if "LimitsLow" in slider_name: mouseClick(waitForObject(slider_object), 0, 0, Qt.LeftButton) test.compare(waitForObject(selected_value_object).visible, True) test.compare(waitForObject(selected_value_object).text, "{0} {1}".format(slider_info["min"], slider_info["units"])) else: test.compare(waitForObject(selected_value_object).visible, True) test.compare(waitForObject(selected_value_object).text, "{0} {1}".format(slider_info["max"], slider_info["units"])) mouseClick(waitForObject(names.o_create_treatment_venousPressureLimitsSlider), 82, 3, Qt.LeftButton) mouseClick(waitForObject(names.o_create_treatment_venousPressureLimitsSlider), 609, 4, Qt.LeftButton) mouseClick(waitForObject(names.o_create_treatment_arterialPressureLimitsSlider), 92, 4, Qt.LeftButton) mouseClick(waitForObject(names.o_create_treatment_arterialPressureLimitsSlider), 563, 5, Qt.LeftButton) print("") def check_button_group(buttons, slider_ranges_key): for idx, btn in enumerate(buttons): mouseClick(waitForObject(btn), waitForObject(btn).width / 2, waitForObject(btn).height / 2, Qt.LeftButton) test.compare(waitForObject(btn).text.text, slider_ranges[slider_ranges_key][idx]) def test_rects(): """ Tests that all possible non-slider options are shown. @return: None """ test.fail("TODO : test_rects() Need to update / remove the testcase to reflect new GUIs and navigation...return") return flick(waitForObject(names.o_create_treatment_flickable), 0, -1100) # acid concentrate acid_options = [ names.o_create_treatment_acid_0, names.o_create_treatment_acid_1, names.o_create_treatment_acid_2 ] check_button_group(acid_options, "acidConcentrateOptions") sleep(2) flick(waitForObject(names.o_create_treatment_flickable), 0, 400) # bicarbonate concentrate bicarbonate_options = [ names.o_create_treatment_bicarbonate_0 ] check_button_group(bicarbonate_options, "bicarbonateConcentrateOptions") # dialyzer type dialyzer_options = [ names.o_create_treatment_dialyzer_0, names.o_create_treatment_dialyzer_1, names.o_create_treatment_dialyzer_2, names.o_create_treatment_dialyzer_3, ] check_button_group(dialyzer_options, "dialyzerTypeOptions") def test_continue_failure(hd_simulator: HDSimulator): """ Tests that continue is disabled by default Simulates a FW response that all parameters are invalid prior to selection. @param hd_simulator: the HDSimulator object @return: None """ test.fail("TODO : Need to update / remove the testcase to reflect new GUIs and navigation...return") return utils.waitForGUI(0.5) flick(waitForObject(names.o_create_treatment_flickable), 0, 2000) # check that UI didn't change the page after prematurely clicking continue test.compare(waitForObject(names.o_create_treatment_continue).visible, True) mouseClick(waitForObject(names.o_create_treatment_continue)) test.compare(waitForObject(names.o_create_treatment_continue).visible, True) test.compare(waitForObject(names.o_create_treatment_rinseback).visible, True) # simulate FW response that all parameters are invalid reject_reasons = [ RequestRejectReasons.REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE ] * hd_simulator.NUM_TREATMENT_PARAMETERS test.compare(hd_simulator.cmd_send_treatment_parameter_validation_response(reject_reasons), True, "Simulate HD treatment param response") def test_continue_success(hd_simulator: HDSimulator): """ Tests that selecting the continue button moves to the treatment confirm page Assumes all treatment parameters have already been selected @param hd_simulator: the HDSimulator object @return: None """ test.fail("TODO : test_continue_success() Need to update / remove the testcase to reflect new GUIs and navigation...return") return flick(waitForObject(names.o_create_treatment_flickable), 0, 700) mouseClick(waitForObject(names.o_create_treatment_continue)) sleep(1) test.compare(waitForObjectExists(names.o_create_treatment_confirm).visible, True) def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME + " -q") hd_simulator = HDSimulator() test_load_create_treatment() test_continue_failure(hd_simulator) test_parameters_exist() test_sliders() test_rects() test_continue_success(hd_simulator) utils.tstDone()