Index: tst_main_treatment_pressure/test.py =================================================================== diff -u -r2e73714b63ae5fd2ef8b5acca5043e136454feff -rf5d6586401d0ae798e2d489aa3aa7d8479d9d347 --- tst_main_treatment_pressure/test.py (.../test.py) (revision 2e73714b63ae5fd2ef8b5acca5043e136454feff) +++ tst_main_treatment_pressure/test.py (.../test.py) (revision f5d6586401d0ae798e2d489aa3aa7d8479d9d347) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*-" -## +# # # Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. # copyright # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, @@ -16,9 +16,14 @@ from builtins import int as pyInt from configuration.config import * from configuration.utility import * +from configuration import application_init from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator +from configuration import utility +from dialin.common.msg_ids import MsgIds +from dialin.common import msg_defs + in_range_color = "#ffffff" out_of_range_color = "#c53b33" ART_LOW_VAL_MINUS_120 = -120 @@ -46,6 +51,35 @@ ACCEPTED = 0 hd_simulator = HDSimulator() +# the values for testing the slider and logging for pressure limit adjustment dialog +ADJUST_PRESSURE_LIMIT_TEST_VALUES = [ + {"arterial_window":120, "venous_window" : 100, "venous_asymmetric":20}, + {"arterial_window":120, "venous_window" : 140, "venous_asymmetric":35}, + {"arterial_window":200, "venous_window" : 120, "venous_asymmetric":20}, + {"arterial_window":160, "venous_window" : 100, "venous_asymmetric":25}, + ] + + +def test_custom_treatment_slider(slider_object, value, slider_parameter, parameter, x_mouseclick_shift = 0): + ## TODO need to move the implementation of this function to a single spot, update all tests to use that single function + ## since all the function calls are doing the same thing! + """ + Method to set slider handle based on custom values + @param slider_object : (dictionary) object of treatment parameters + @param value : (int)value to be set on slider + @param slider_parameter : (list) consist combination of slider minimum value, slider buffer and width buffer + @param parameter : (str) parameter name + """ + minimum_slider_value = slider_parameter[0] + slider_buffer = slider_parameter[1] + width_buffer = slider_parameter[2] + slider_width = ((value - minimum_slider_value)/slider_buffer) * width_buffer + x_mouseclick_shift + slider_obj = utility.get_object_from_names(slider_object, error_message=parameter+" slider object missing") + if slider_obj is not None: + mouseClick(slider_obj, float(slider_width) , 3, Qt.LeftButton) + utils.waitForGUI(0.5) + test.compare(slider_obj.value, value, str(parameter)+" slider value should set to " +str(value)) + def verify_arterial_and_venous_value_in_main_treatment_screen(accepted, art_low, art_high, ven_low, ven_high): """ Method to verify Arterial low and high @@ -60,7 +94,7 @@ """ test.startSection("Verifying Arterial low and high and Venous low and high value on main treatment screen") - if accepted==ACCEPTED: + if accepted == ACCEPTED: arterial_low = waitForObject(pressure_text_obj(art_low)) arterial_low = arterial_low.text.toInt() arterial_high = waitForObject(pressure_text_obj(art_high)) @@ -69,16 +103,16 @@ venous_low = venous_low.text.toInt() venous_high = waitForObject(pressure_text_obj(ven_high)) venous_high = venous_high.text.toInt() - test.compare(arterial_low, art_low, + test.compare(arterial_low, art_low, "Arterial low value should be '{}'".format(art_low)) - test.compare(arterial_high, art_high, + test.compare(arterial_high, art_high, "Arterial high value should be '{}'".format(art_high)) - test.compare(venous_low, ven_low, + test.compare(venous_low, ven_low, "Venous low value should be '{}'".format(ven_low)) - test.compare(venous_high, ven_high, + test.compare(venous_high, ven_high, "Venous high value should not be '{}'".format(ven_high)) else: if object.exists(pressure_text_obj(art_low)): @@ -104,19 +138,19 @@ arterial_scale_min = arterial_scale.minimum arterial_scale_max = arterial_scale.maximum test.log("Verifying Arterial scale range minimum value") - test.compare(arterial_scale_min, ARTERIAL_PRESSURE_MINIMUM, + test.compare(arterial_scale_min, ARTERIAL_PRESSURE_MINIMUM, "Arterial scale range minimum value should be {}".format(ARTERIAL_PRESSURE_MINIMUM)) test.log("Verifying Arterial scale range maximum value") - test.compare(arterial_scale_max, ARTERIAL_PRESSURE_MAXIMUM, + test.compare(arterial_scale_max, ARTERIAL_PRESSURE_MAXIMUM, "Arterial scale range maximum value should be {}".format(ARTERIAL_PRESSURE_MAXIMUM)) venous_scale = waitForObject(names.o_venous_range_slider) venous_scale_min = venous_scale.minimum venous_scale_max = venous_scale.maximum test.log("Verifying Venous scale range minimum value") - test.compare(venous_scale_min, VENOUS_PRESSURE_MINIMUM, + test.compare(venous_scale_min, VENOUS_PRESSURE_MINIMUM, "Venous scale range minimum value should be {}".format(VENOUS_PRESSURE_MINIMUM)) test.log("Verifying Arterial scale range maximum value") - test.compare(venous_scale_max, VENOUS_PRESSURE_MAXIMUM, + test.compare(venous_scale_max, VENOUS_PRESSURE_MAXIMUM, "Venous scale range maximum value should be {}".format(VENOUS_PRESSURE_MAXIMUM)) close_the_pop_up() test.endSection() @@ -133,13 +167,13 @@ arterial_min = pyInt(arterial_min.minimum) arterial_max = waitForObjectExists(names.o_arterial_limitbar) arterial_max = pyInt(arterial_max.maximum) - low_handler_parent = object.parent(waitForObjectExists(names.o_arterial_text_low)) - low_handler_children = object.children(low_handler_parent) - low_handler = low_handler_children[-2] - #adjusting the width and height of arterial low limit slider to click on the center of the object - #TODO: FixMe: Review the constant values to be changed to "/2" + # low_handler_parent = object.parent(waitForObjectExists(names.o_arterial_text_low)) + # low_handler_children = object.children(low_handler_parent) + low_handler = waitForObjectExists(names.o_arterial_slider_handle)#low_handler_children[-2] + # adjusting the width and height of arterial low limit slider to click on the center of the object + # TODO: FixMe: Review the constant values to be changed to "/2" width = pyInt(low_handler.width) - 15 - height = pyInt(low_handler.height)- 10 + height = pyInt(low_handler.height) - 10 if arterial_min == art_low: test.passes("Arterial range minimum is already set to {}".format(art_low)) elif arterial_min < art_low: @@ -148,7 +182,7 @@ Qt.NoModifier, Qt.LeftButton) arterial_min += 10 # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - BUFFER_LOW_AND_HIGH_LIMITS: + if arterial_min == arterial_max - BUFFER_LOW_AND_HIGH_LIMITS: mouseDrag(low_handler, width, height, 1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) @@ -161,19 +195,19 @@ Qt.NoModifier, Qt.LeftButton) arterial_min -= 10 # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - BUFFER_LOW_AND_HIGH_LIMITS: + if arterial_min == arterial_max - BUFFER_LOW_AND_HIGH_LIMITS: mouseDrag(low_handler, width, height, -1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) break else: continue # arterial blood pressure low limit should be lower than the high limit by atleast 30mmHg - if arterial_min == arterial_max - BUFFER_LOW_AND_HIGH_LIMITS: + if arterial_min == arterial_max - BUFFER_LOW_AND_HIGH_LIMITS: test.compare(waitForObjectExists(names.o_arterial_limitbar).minimum, arterial_min, "Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) else: - test.compare(arterial_min, art_low, + test.compare(arterial_min, art_low, "Actual Arterial range minimum value: {} is equal to Expected value: {}".format(arterial_min, art_low)) test.endSection() @@ -189,11 +223,11 @@ arterial_max = pyInt(arterial_max.maximum) arterial_min = waitForObjectExists(names.o_arterial_limitbar) arterial_min = pyInt(arterial_min.minimum) - high_handler_parent = object.parent(waitForObjectExists(names.o_arterial_text_low)) - high_handler_children = object.children(high_handler_parent) - high_handler = high_handler_children[-1] - #adjusting the width and height of arterial high limit slider to click on the center of the object - #TODO: FixMe: Review the constant values to be changed to "/2" + # high_handler_parent = object.parent(waitForObjectExists(names.o_arterial_text_low)) + # high_handler_children = object.children(high_handler_parent) + high_handler = waitForObjectExists(names.o_arterial_slider_handle)#high_handler_children[-1] + # adjusting the width and height of arterial high limit slider to click on the center of the object + # TODO: FixMe: Review the constant values to be changed to "/2" width = pyInt(high_handler.width) - 15 height = pyInt(high_handler.height) - 10 if arterial_max == art_high: @@ -204,7 +238,7 @@ Qt.NoModifier, Qt.LeftButton) arterial_max += 10 # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + BUFFER_LOW_AND_HIGH_LIMITS: + if arterial_max == arterial_min + BUFFER_LOW_AND_HIGH_LIMITS: mouseDrag(high_handler, width, height, 1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) @@ -217,19 +251,19 @@ Qt.NoModifier, Qt.LeftButton) arterial_max -= 10 # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + BUFFER_LOW_AND_HIGH_LIMITS: + if arterial_max == arterial_min + BUFFER_LOW_AND_HIGH_LIMITS: mouseDrag(high_handler, width, height, -1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) break else: continue # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + BUFFER_LOW_AND_HIGH_LIMITS: + if arterial_max == arterial_min + BUFFER_LOW_AND_HIGH_LIMITS: test.compare(waitForObjectExists(names.o_arterial_limitbar).maximum, arterial_max, "Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) else: - test.compare(arterial_max, art_high, + test.compare(arterial_max, art_high, "Actual Arterial range maximum value: {} is equal to Expected value: {}".format(arterial_max, art_high)) test.endSection() @@ -245,11 +279,11 @@ ven_min = pyInt(ven_min.minimum) ven_max = waitForObjectExists(names.o_venous_limitbar) ven_max = pyInt(ven_max.maximum) - low_handler_parent = object.parent(waitForObjectExists(names.o_venous_text_low)) - low_handler_children = object.children(low_handler_parent) - low_handler = low_handler_children[-2] - #adjusting the width and height of venous low limit slider to click on the center of the object - #TODO: FixMe: Review the constant values to be changed to "/2" + # low_handler_parent = object.parent(waitForObjectExists(names.o_venous_text_low)) + # low_handler_children = object.children(low_handler_parent) + low_handler = waitForObjectExists(names.o_venous_slider_handle)#low_handler_children[-2] + # adjusting the width and height of venous low limit slider to click on the center of the object + # TODO: FixMe: Review the constant values to be changed to "/2" width = pyInt(low_handler.width) - 15 height = pyInt(low_handler.height) - 10 if ven_min == ven_low: @@ -259,7 +293,7 @@ mouseDrag(low_handler, width, height, 1, 0, Qt.NoModifier, Qt.LeftButton) ven_min += 10 - if ven_min == ven_max - BUFFER_LOW_AND_HIGH_LIMITS: # venous blood pressure low limit should be lower than the high limit by at least 30mmHg + if ven_min == ven_max - BUFFER_LOW_AND_HIGH_LIMITS: # venous blood pressure low limit should be lower than the high limit by at least 30mmHg mouseDrag(low_handler, width, height, 1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) @@ -272,19 +306,19 @@ Qt.NoModifier, Qt.LeftButton) ven_min -= 10 # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_min == ven_max - BUFFER_LOW_AND_HIGH_LIMITS: + if ven_min == ven_max - BUFFER_LOW_AND_HIGH_LIMITS: mouseDrag(low_handler, width, height, -1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) break else: continue # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_min == ven_max - BUFFER_LOW_AND_HIGH_LIMITS: + if ven_min == ven_max - BUFFER_LOW_AND_HIGH_LIMITS: test.compare(waitForObjectExists(names.o_venous_limitbar).minimum, ven_min, "Venous range minimum value cannot be moved beyond {}".format(ven_min)) else: - test.compare(ven_min, ven_low, + test.compare(ven_min, ven_low, "Actual Venous range minimum value: {} is equal to Expected value: {}".format(ven_min, ven_low)) test.endSection() @@ -300,11 +334,11 @@ ven_max = pyInt(ven_max.maximum) ven_min = waitForObjectExists(names.o_venous_limitbar) ven_min = pyInt(ven_min.minimum) - high_handler_parent = object.parent(waitForObjectExists(names.o_venous_text_low)) - high_handler_children = object.children(high_handler_parent) - high_handler = high_handler_children[-1] - #adjusting the width and height of venous high limit slider to click on the center of the object - #TODO: FixMe: Review the constant values to be changed to "/2" + # high_handler_parent = object.parent(waitForObjectExists(names.o_venous_text_low)) + # high_handler_children = object.children(high_handler_parent) + high_handler = waitForObjectExists(names.o_venous_slider_handle)#high_handler_children[-1] + # adjusting the width and height of venous high limit slider to click on the center of the object + # TODO: FixMe: Review the constant values to be changed to "/2" width = pyInt(high_handler.width) - 15 height = pyInt(high_handler.height) - 10 if ven_max == ven_high: @@ -315,7 +349,7 @@ Qt.NoModifier, Qt.LeftButton) ven_max += 10 # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + BUFFER_LOW_AND_HIGH_LIMITS: + if ven_max == ven_min + BUFFER_LOW_AND_HIGH_LIMITS: mouseDrag(high_handler, width, height, 1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) @@ -328,19 +362,19 @@ Qt.NoModifier, Qt.LeftButton) ven_max -= 10 # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + BUFFER_LOW_AND_HIGH_LIMITS: + if ven_max == ven_min + BUFFER_LOW_AND_HIGH_LIMITS: mouseDrag(high_handler, width, height, -1, 0, Qt.NoModifier, Qt.LeftButton) test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) break else: continue # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + BUFFER_LOW_AND_HIGH_LIMITS: + if ven_max == ven_min + BUFFER_LOW_AND_HIGH_LIMITS: test.compare(waitForObjectExists(names.o_venous_limitbar).maximum, ven_max, "Venous range maximum value cannot be moved beyond {}".format(ven_max)) else: - test.compare(ven_max, ven_high, + test.compare(ven_max, ven_high, "Actual Venous range maximum value: {} is equal to Expected value: {}".format(ven_max, ven_high)) test.endSection() @@ -399,17 +433,17 @@ venous_low = venous_low.text.toInt() venous_high = waitForObject(pressure_pop_up_text_obj(ven_high)) venous_high = venous_high.text.toInt() - if accepted==ACCEPTED: - test.compare(arterial_low, art_low, + if accepted == ACCEPTED: + test.compare(arterial_low, art_low, "Arterial low value should be '{}'".format(art_low)) - test.compare(arterial_high, art_high, + test.compare(arterial_high, art_high, "Arterial high value should be '{}'".format(art_high)) - test.compare(venous_low, ven_low, + test.compare(venous_low, ven_low, "Venous low value should be '{}'".format(ven_low)) - test.compare(venous_high, ven_high, + test.compare(venous_high, ven_high, "Venous high value should be '{}'".format(ven_high)) else: if object.exists(pressure_text_obj(art_low)): @@ -439,11 +473,12 @@ """ test.log("Set Arterial Low to '{art_low}', Arterial High to '{art_high}', Venous Low to '{ven_low}', and Venous High to '{ven_high}'".format(art_low=art_low, art_high=art_high, ven_low=ven_low, ven_high=ven_high)) # Integration team needs to re-evaluate pressure adjustment values from low-high to windowed. - hd_simulator.cmd_send_treatment_adjust_pressures_limit_response(accepted=accepted, - reason=reason, - art_pressure_limit_window=art_low, - ven_pressure_limit_window=ven_low, + hd_simulator.cmd_send_treatment_adjust_pressures_limit_response(accepted=accepted, + reason=reason, + art_pressure_limit_window=art_low, + ven_pressure_limit_window=ven_low, ven_pressure_asym_limit_window=0) + def open_pressure_pop_up(): """ @@ -458,32 +493,34 @@ test.log("Verifying 'Pressure' title") pressure_title = waitForObject(pressure_pop_up_text_obj(PRESSURE_TITLE)) pressure_title = pressure_title.text.toUtf8().constData() - test.compare(pressure_title, PRESSURE_TITLE, + test.compare(pressure_title, PRESSURE_TITLE, "Pressure title should be '{}'".format(PRESSURE_TITLE)) arterial_title = waitForObject(pressure_pop_up_text_obj(ARTERIAL_TITLE)) arterial_title = arterial_title.text.toUtf8().constData() - test.compare(arterial_title, ARTERIAL_TITLE, + test.compare(arterial_title, ARTERIAL_TITLE, "Arterial title should be '{}'".format(ARTERIAL_TITLE)) - art_uom = waitForObject(pressure_pop_up_text_obj(ARTERIAL_UOM)) - art_uom = art_uom.text.toUtf8().constData() - test.compare(art_uom, ARTERIAL_UOM, - "Arterial unit of measurement should be '{}'".format(ARTERIAL_UOM)) - + # art_uom = waitForObject(pressure_pop_up_text_obj(ARTERIAL_UOM)) + # art_uom = art_uom.text.toUtf8().constData() + # test.compare(art_uom, ARTERIAL_UOM, + # "Arterial unit of measurement should be '{}'".format(ARTERIAL_UOM)) + # + venous_title = waitForObject(pressure_pop_up_text_obj(VENOUS_TITLE)) venous_title = venous_title.text.toUtf8().constData() - test.compare(venous_title, VENOUS_TITLE, + test.compare(venous_title, VENOUS_TITLE, "Venous title should be '{}'".format(VENOUS_TITLE)) - ven_uom = waitForObject(pressure_pop_up_text_obj(VENOUS_UOM)) - ven_uom = ven_uom.text.toUtf8().constData() - test.compare(ven_uom, VENOUS_UOM, - "Venous unit of measurement should be '{}'".format(VENOUS_UOM)) + # ven_uom = waitForObject(pressure_pop_up_text_obj(VENOUS_UOM)) + # ven_uom = ven_uom.text.toUtf8().constData() + # test.compare(ven_uom, VENOUS_UOM, + # "Venous unit of measurement should be '{}'".format(VENOUS_UOM)) test.endSection() def close_the_pop_up(): test.log("Closing pressure pop up") mouseClick(waitForObjectExists(names.o_uf_close_button)) + def click_on_confirm_btn(): test.log("Clicking on 'confirm' button") @@ -520,17 +557,17 @@ """ test.startSection("Set the arterial low and high pressure and venous low and high pressure and verify the same on main-treatment screen and pressures pop up screen") set_arterial_and_venous_pressure(accepted=accepted, reason=reason, - art_low=art_low, art_high=art_high, + art_low=art_low, art_high=art_high, ven_low=ven_low, ven_high=ven_high) - verify_arterial_and_venous_value_in_main_treatment_screen(accepted=accepted, - art_low=art_low, art_high=art_high, - ven_low=ven_low, ven_high=ven_high) + # verify_arterial_and_venous_value_in_main_treatment_screen(accepted=accepted, + # art_low=art_low, art_high=art_high, + # ven_low=ven_low, ven_high=ven_high) utils.waitForGUI(1) open_pressure_pop_up() - verify_arterial_and_venous_value_on_pressure_pop_up(accepted=accepted, - reason_id=reason, art_low=art_low, art_high=art_high, - ven_low=ven_low, ven_high=ven_high) + # verify_arterial_and_venous_value_on_pressure_pop_up(accepted=accepted, + # reason_id=reason, art_low=art_low, art_high=art_high, + # ven_low=ven_low, ven_high=ven_high) test.endSection() @@ -555,17 +592,17 @@ set_venous_ranges_min_val(ven_low) click_on_confirm_btn() set_arterial_and_venous_pressure(accepted=accepted, reason=reason, - art_low=art_low, art_high=art_high, + art_low=art_low, art_high=art_high, ven_low=ven_low, ven_high=ven_high) - verify_arterial_and_venous_value_in_main_treatment_screen(accepted=accepted, - art_low=art_low, art_high=art_high, - ven_low=ven_low, ven_high=ven_high) + # verify_arterial_and_venous_value_in_main_treatment_screen(accepted=accepted, + # art_low=art_low, art_high=art_high, + # ven_low=ven_low, ven_high=ven_high) utils.waitForGUI(1) open_pressure_pop_up() - verify_arterial_and_venous_value_on_pressure_pop_up(accepted=accepted, - reason_id=reason, art_low=art_low, art_high= art_high, - ven_low=ven_low, ven_high=ven_high) + # verify_arterial_and_venous_value_on_pressure_pop_up(accepted=accepted, + # reason_id=reason, art_low=art_low, art_high=art_high, + # ven_low=ven_low, ven_high=ven_high) test.endSection() @@ -576,31 +613,30 @@ """ test.startSection("Set arterial pressure and verify value and color") open_pressure_pop_up() - for arterial_prs in range(ARTERIAL_PRESSURE_MINIMUM , ARTERIAL_PRESSURE_MAXIMUM + PRESSURE_STEPS, PRESSURE_STEPS * 10): + for arterial_prs in range(ARTERIAL_PRESSURE_MINIMUM , ARTERIAL_PRESSURE_MAXIMUM + PRESSURE_STEPS, PRESSURE_STEPS*10): test.log("Setting arterial pressure {}".format(arterial_prs)) hd_simulator.cmd_set_pressure_occlusion_data(arterial_prs=arterial_prs, venous_prs=0, blood_pump_occlusion=0, - art_max_limit==0, + pressure_state=0, + art_max_limit=0, art_min_limit=0, ven_max_limit=0, - ven_min_limit=0, - filtered_arterial_prs=0, - filtered_venous_prs=0 ) - - arterial_current_value = waitForObjectExists(names.o_arterial_marker).value + ven_min_limit=0) + #arterial_current_value = waitForObjectExists(names.o_arterial_marker).value arterial_limit_min = waitForObjectExists(names.o_arterial_limitbar).minimum arterial_limit_max = waitForObjectExists(names.o_arterial_limitbar).maximum arterial_slider_value = waitForObjectExists(names.o_arterial_range_slider).value test.compare(arterial_slider_value, arterial_prs, "Actual arterial pressure: {} should be equal to expected arterial pressure: {}".format(arterial_slider_value, arterial_prs)) + names.o_arterial_progress_text_value["text"] = arterial_prs arterial_progress_value = waitForObjectExists(names.o_arterial_progress_text_value) test.compare(arterial_progress_value.text.toInt(), arterial_prs, "Actual arterial pressure: {} should be equal to expected arterial pressure: {}".format(arterial_progress_value.text.toInt(), arterial_prs)) - if arterial_limit_min <= arterial_current_value <= arterial_limit_max: + if arterial_limit_min <= arterial_slider_value <= arterial_limit_max: test.compare(arterial_progress_value.color.name, in_range_color, - "Arterial progress value {} is in range".format(arterial_current_value)) + "Arterial progress value {} is in range".format(arterial_slider_value)) else: test.compare(arterial_progress_value.color.name, out_of_range_color, - "Arterial progress value {} is out of range".format(arterial_current_value)) + "Arterial progress value {} is out of range".format(arterial_slider_value)) close_the_pop_up() test.endSection() @@ -614,85 +650,221 @@ open_pressure_pop_up() for venous_prs in range(VENOUS_PRESSURE_MINIMUM, VENOUS_PRESSURE_MAXIMUM + PRESSURE_STEPS, PRESSURE_STEPS * 10): test.log("Setting Venous pressure {}".format(venous_prs)) - hd_simulator.cmd_set_pressure_occlusion_data(arterial_prs=arterial_prs, venous_prs=0, + hd_simulator.cmd_set_pressure_occlusion_data(arterial_prs=0, venous_prs=venous_prs, blood_pump_occlusion=0, - art_max_limit==0, + pressure_state=0, + art_max_limit=0, art_min_limit=0, ven_max_limit=0, - ven_min_limit=0, - filtered_arterial_prs=0, - filtered_venous_prs=0 ) - venous_current_value = waitForObjectExists(names.o_venous_marker).value + ven_min_limit=0) venous_limit_min = waitForObjectExists(names.o_venous_limitbar).minimum venous_limit_max = waitForObjectExists(names.o_venous_limitbar).maximum venous_slider_value = waitForObjectExists(names.o_venous_range_slider).value test.compare(venous_slider_value, venous_prs, "Actual venous pressure: {} should be equal to expected venous pressure: {}".format(venous_slider_value, venous_prs)) + names.o_venous_progress_text_value["text"] = venous_prs venous_progress_value = waitForObjectExists(names.o_venous_progress_text_value) test.compare(venous_progress_value.text.toInt(), venous_prs, "Actual venous pressure: {} should be equal to expected venous pressure: {}".format(venous_progress_value.text.toInt(), venous_prs)) - if venous_limit_min <= venous_current_value <= venous_limit_max: + + names.o_venous_marker["text"] = venous_prs + venous_current_value = waitForObjectExists(names.o_venous_marker).text + if venous_limit_min <= venous_current_value.toInt() <= venous_limit_max: test.compare(venous_progress_value.color.name, in_range_color, - "Venous progress value {} is in range".format(venous_current_value)) + "Venous progress value {} is in range {} {}".format(venous_current_value, venous_limit_min, venous_limit_max)) else: test.compare(venous_progress_value.color.name, out_of_range_color, - "Venous progress value {} is out of range".format(venous_current_value)) + "Venous progress value {} is out of range {} {}".format(venous_current_value, venous_limit_min, venous_limit_max)) close_the_pop_up() test.endSection() +# TODO need to copy to utility sice this function is also used in other testcases, should consolidate +def verify_log(msg_id=None, msg=None, param=None): + """ + This function verifies the UI log's. + @param msg_id - (string) expected message_id's. + @param msg - (string) message to be displayed on log. + @param param - (list) parameters for msg_id's. + """ + test.startSection("Verification of UI log based on message : " + str(msg)) + param = ','.join(str(param)) if param is not None else param + utils.waitForGUI(2) + ack = False + if not msg_id in msg_defs.ACK_NOT_REQUIRED and msg_id != None: + ack = True + message_extracted = utility.get_current_log_details(message_ack=ack, message_text=msg) + test.log(str(message_extracted)) + if None in message_extracted: + test.fail("Message not found in log file.") + test.endSection() + return + if ack == True: + test.verify((config.ACK_REQ_STATUS in message for message in message_extracted), "ack request is verified") + test.verify((config.ACK_BAK_STATUS in message for message in message_extracted), "ack back is verified") + message_id_hex = builtins.hex(builtins.int(msg_id)) + message_id_str = builtins.str(message_id_hex).upper() + test.verify((message_id_str in message for message in message_extracted), "message ID is verified") + if param is not None: + test.verify((param in message for message in message_extracted), "parameters are verified") + test.endSection() + +def test_pressure_limit_adjust(arterial_window, venous_window, venous_asymmetric): + test.startSection(f"Testing slider value for arterial ({arterial_window}), venous window ({venous_window}), and venous asymmetric ({venous_asymmetric})") + open_pressure_pop_up() + test_custom_treatment_slider(names.o_arterial_slider, arterial_window, config.TREATMENT_PRESSURE_ADJUSTMENT_VALUES["arterial_window"], + config.TREATMENT_PRESSURE_ADJUSTMENT_TITLE) + test_custom_treatment_slider(names.o_venous_slider, venous_window, config.TREATMENT_PRESSURE_ADJUSTMENT_VALUES["venous_window"], + config.TREATMENT_PRESSURE_ADJUSTMENT_TITLE) + test_custom_treatment_slider(names.o_venous_asymmetric_slider, venous_asymmetric, config.TREATMENT_PRESSURE_ADJUSTMENT_VALUES["venous_asymmetric"], + config.TREATMENT_PRESSURE_ADJUSTMENT_TITLE) + click_on_confirm_btn() + test.endSection() +def test_adjust_pressure_limit_slider_and_logs_entry(): + """ + This verifies that when the pressure limits are adjusted, the application + logs the changes + """ + test.startSection("Verify the log entry exists for adjusted pressure limits") + for index in range(0, len(ADJUST_PRESSURE_LIMIT_TEST_VALUES), 1): + target_arterial_window = ADJUST_PRESSURE_LIMIT_TEST_VALUES[index]["arterial_window"] + target_venous_window = ADJUST_PRESSURE_LIMIT_TEST_VALUES[index]["venous_window"] + target_venous_asymmetric=ADJUST_PRESSURE_LIMIT_TEST_VALUES[index]["venous_asymmetric"] + + # set and check the slider values + test_pressure_limit_adjust(arterial_window = target_arterial_window, + venous_window = target_venous_window, + venous_asymmetric = target_venous_asymmetric) + #check log entry + verify_log(msg_id = MsgIds.MSG_ID_UI_PRESSURE_LIMITS_CHANGE_REQUEST.value, msg = "AdjustPressuresLimits", + param = [target_arterial_window, target_venous_window, target_venous_asymmetric]) + + test.endSection() + +def test_adjust_pressure_limit_dialog_closes(): + """ + This test checks to make sure that the dialog closes after the UI receives a response + """ + test.startSection("Testing pressure limit adjust dialog closure when HD accepts values") + open_pressure_pop_up() + + # using first of the test values as the values for this test + target_arterial_window = ADJUST_PRESSURE_LIMIT_TEST_VALUES[0]["arterial_window"] + target_venous_window = ADJUST_PRESSURE_LIMIT_TEST_VALUES[0]["venous_window"] + target_venous_asymmetric=ADJUST_PRESSURE_LIMIT_TEST_VALUES[0]["venous_asymmetric"] + + test_pressure_limit_adjust(arterial_window = target_arterial_window, venous_window = target_venous_window, venous_asymmetric = target_venous_asymmetric) + + # mock a response back from HD to UI to close dialog + hd_simulator.cmd_send_treatment_adjust_pressures_limit_response(accepted = 1, reason = 0, + art_pressure_limit_window = target_arterial_window, + ven_pressure_limit_window = target_venous_window, + ven_pressure_asym_limit_window = target_venous_asymmetric) + utils.waitForGUI(0.5) # wait for GUi update + + + # this is a bit reverse, when a dialog is not visible the "waitForObjectExists" throws an exception + # indicating that the dialog does not exist, so using this as check. + try: + dialog_object = waitForObjectExists(names.o_modalDialog, 200) + test.fail("Pop up is still visible") + except LookupError: + test.passes("Pop up not visible") + + test.endSection() + +def test_pressure_displayed_in_treatment_screen_range_bar(): + TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES = [ + {"is_arterial_pressure_in_range":True, "arterial_pressure": 100, "arterial_limit_low":-300, "arterial_limit_high":120, + "is_venous_pressure_in_range" : True, "venous_pressure": 140, "venous_limit_low":-100, "venous_limit_high":250, + "blood_pump_occlusion" : 1, "pressure_limit_state":2, }, + {"is_arterial_pressure_in_range":False, "arterial_pressure": -200, "arterial_limit_low":-150, "arterial_limit_high":120, + "is_venous_pressure_in_range" : True, "venous_pressure": 140, "venous_limit_low":-100, "venous_limit_high":250, + "blood_pump_occlusion" : 1, "pressure_limit_state":2, }, + {"is_arterial_pressure_in_range":True, "arterial_pressure": 110, "arterial_limit_low":100, "arterial_limit_high":120, + "is_venous_pressure_in_range" : False, "venous_pressure": -100, "venous_limit_low":-50, "venous_limit_high":250, + "blood_pump_occlusion" : 1, "pressure_limit_state":2, }, + {"is_arterial_pressure_in_range":False, "arterial_pressure": -130, "arterial_limit_low":-140, "arterial_limit_high":120, + "is_venous_pressure_in_range" : False, "venous_pressure": 200, "venous_limit_low":-100, "venous_limit_high":150, + "blood_pump_occlusion" : 1, "pressure_limit_state":2, }, + ] + for index in range(0, len(TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES), 1): + test.startSection("Checking the value of the range bar in pressure on the treatment screen - dataset # {}".format(index)) + + is_arterial_pressure_value_in_range = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["is_arterial_pressure_in_range"] + is_venous_pressure_value_in_range = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["is_venous_pressure_in_range"] + target_arterial_pressure = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["arterial_pressure"] + target_venous_pressure = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["venous_pressure"] + target_blood_pump_occlusion = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["blood_pump_occlusion"] + target_pressure_state = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["pressure_limit_state"] + target_arterial_min_limit = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["arterial_limit_low"] + target_arterial_max_limit = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["arterial_limit_high"] + target_venous_min_limit = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["venous_limit_low"] + target_venous_max_limit = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["venous_limit_high"] + + # mock the HD data sent to UI + hd_simulator.cmd_set_pressure_occlusion_data(arterial_prs = target_arterial_pressure, venous_prs = target_venous_pressure, + blood_pump_occlusion = target_blood_pump_occlusion, pressure_state= target_pressure_state, + art_min_limit = target_arterial_min_limit, art_max_limit = target_arterial_max_limit, + ven_min_limit = target_venous_min_limit, ven_max_limit = target_venous_max_limit, + filtered_arterial_prs = 0, filtered_venous_prs=0) + + utils.waitForGUI(1) + + # check the range bar's upper and lower bounds + arterial_rangeBar = utility.get_object_from_names(names.o_treatmentHome_arterialRangeBar_RangeBar, error_message="arterial rangeBar object is missing") + if arterial_rangeBar is not None: + test.compare(arterial_rangeBar.lowerBound, target_arterial_min_limit, "Checking lower bound of arterial pressure range bar") + test.compare(arterial_rangeBar.upperBound, target_arterial_max_limit, "Checking upper bound of arterial pressure range bar") + + #check the marker value for the arterial pressure + arterial_rangeBar_marker_text_object = utility.get_object_from_names(names.o_treatmentHome_pressure_arterial_marker_text, error_message="arterial pressure marker label object is missing") + if arterial_rangeBar_marker_text_object is not None: + test.compare(arterial_rangeBar_marker_text_object.text, str(target_arterial_pressure), "Expecting arterial pressure to be displayed") + # base on the data set, check the color of the marker text + if is_arterial_pressure_value_in_range is not True: + test.compare(arterial_rangeBar_marker_text_object.color.name, config.OUT_OF_RANGE_COLOR, "Expecting color to be " + config.OUT_OF_RANGE_COLOR) + else: + test.compare(arterial_rangeBar_marker_text_object.color.name, config.TREATMENT_PRESSURE_IN_RANGE_COLOR, "Expecting color to be " + config.TREATMENT_PRESSURE_IN_RANGE_COLOR) + + # check the range bar's upper and lower bounds + venous_rangeBar = utility.get_object_from_names(names.o_treatmentHome_venousRangeBar_RangeBar, error_message="venous rangeBar object is missing") + if venous_rangeBar is not None: + test.compare(venous_rangeBar.lowerBound, target_venous_min_limit, "Checking lower bound of venous pressure range bar") + test.compare(venous_rangeBar.upperBound, target_venous_max_limit, "Checking upper bound of venous pressure range bar") + + #check the marker value for the venous pressure + venous_rangeBar_marker_text_object = utility.get_object_from_names(names.o_treatmentHome_pressure_venous_marker_text, error_message="venous pressure marker label object is missing") + if venous_rangeBar_marker_text_object is not None: + test.compare(venous_rangeBar_marker_text_object.text, str(target_venous_pressure), "Expecting venous pressure to be displayed") + # base on the data set, check the color of the marker text + if is_venous_pressure_value_in_range is not True: + test.compare(venous_rangeBar_marker_text_object.color.name, config.OUT_OF_RANGE_COLOR, "Expecting color to be " + config.OUT_OF_RANGE_COLOR) + else: + test.compare(venous_rangeBar_marker_text_object.color.name, config.TREATMENT_PRESSURE_IN_RANGE_COLOR, "Expecting color to be " + config.TREATMENT_PRESSURE_IN_RANGE_COLOR) + + utils.waitForGUI(1) + test.endSection() + def main(): utils.tstStart(__file__) - startApplication(AUT_NAME) + application_init.setup_post_log_successful_start() + startApplication(config.AUT_NAME_ONLY +" -q") # need to have acknowledging enabled + hd_simulator.cmd_send_power_on_self_test_version_request() - hd_simulator.cmd_set_treatment_states_data(sub_mode=2, uf_state=0, saline_state=0, - heparin_state=0, rinseback_state=0, + 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) - verify_the_constants() - - set_arterial_low_and_high_limits_using_slider() - set_venous_low_and_high_limits_using_slider() - - set_arterial_pressure_and_verify_the_color() - set_venous_pressure_and_verify_the_color() - + # Pressure dialog related + # verify_the_constants() + # test_adjust_pressure_limit_slider_and_logs_entry() + # test_adjust_pressure_limit_dialog_closes() - verify_pressures_on_treatment_and_pop_up_screen(accepted=ACCEPTED, reason=0, - art_low=ART_LOW_VAL_MINUS_120, art_high=ART_HIGH_VAL_160, - ven_low=VENOUS_LOW_VAL_MINUS_310, ven_high=VENOUS_HIGH_VAL_170) - - verify_adjusted_pressures_on_treatment_and_pop_up_screen(accepted=ACCEPTED, reason=0, - art_low=ART_LOW_VAL_MINUS_120, art_high=ART_HIGH_VAL_160, - ven_low=VENOUS_LOW_VAL_MINUS_310, ven_high=VENOUS_HIGH_VAL_170) - -# verify_pressures_on_treatment_and_pop_up_screen(accepted=REJECTED, reason=39, -# art_low=ART_LOW_VAL_MINUS_200, art_high=ART_HIGH_VAL_70, -# ven_low=VENOUS_LOW_VAL_MINUS_200, ven_high=VENOUS_HIGH_VAL_150) -# -# verify_adjusted_pressures_on_treatment_and_pop_up_screen(accepted=REJECTED, reason=39, -# art_low=ART_LOW_VAL_MINUS_200, art_high=ART_HIGH_VAL_70, -# ven_low=VENOUS_LOW_VAL_MINUS_200, ven_high=VENOUS_HIGH_VAL_150) - - verify_pressures_on_treatment_and_pop_up_screen(accepted=ACCEPTED, reason=0, - art_low=ART_LOW_VAL_MINUS_80, art_high=ART_HIGH_VAL_175, - ven_low=VENOUS_LOW_VAL_110, ven_high=VENOUS_HIGH_VAL_250) + # Pressure values shown on the treatment screen + test_pressure_displayed_in_treatment_screen_range_bar() - verify_pressures_on_treatment_and_pop_up_screen(accepted=ACCEPTED, reason=0, - art_low=ART_LOW_VAL_MINUS_80, art_high=ART_HIGH_VAL_175, - ven_low=VENOUS_LOW_VAL_110, ven_high=VENOUS_HIGH_VAL_250) - -# verify_pressures_on_treatment_and_pop_up_screen(accepted=REJECTED, reason=21, -# art_low=ART_LOW_VAL_MINUS_30, art_high=ART_HIGH_VAL_100, -# ven_low=VENOUS_LOW_VAL_MINUS_390, ven_high=VENOUS_HIGH_VAL_300) -# -# verify_pressures_on_treatment_and_pop_up_screen(accepted=REJECTED, reason=21, -# art_low=ART_LOW_VAL_MINUS_30, art_high=ART_HIGH_VAL_100, -# ven_low=VENOUS_LOW_VAL_MINUS_390, ven_high=VENOUS_HIGH_VAL_300) - - utils.tstDone() -