# -*- 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_main_treatment_pressure # date 18/feb/2022 # author Papiya Mandal import names from configuration.config import * from configuration.utility import * from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator ART_LOW_VAL_MINUS_120 = -120 ART_HIGH_VAL_160 = 160 ART_LOW_VAL_MINUS_200 = -200 ART_HIGH_VAL_100 = 100 ART_LOW_VAL_MINUS_30 = -30 ART_HIGH_VAL_70 = 70 ART_LOW_VAL_MINUS_80 = -80 ART_HIGH_VAL_175 = 175 VENOUS_LOW_VAL_MINUS_200 = -200 VENOUS_HIGH_VAL_150 = 150 VENOUS_LOW_VAL_MINUS_310 = -310 VENOUS_HIGH_VAL_170 = 170 VENOUS_LOW_VAL_MINUS_390 = -390 VENOUS_HIGH_VAL_300 = 300 VENOUS_LOW_VAL_110 = 110 VENOUS_HIGH_VAL_250 = 250 hd = HDSimulator() 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 and Venous low and high value on main treatment screen @param accepted: (int) boolean accept/reject response @param arterial_low: (int) Arterial Pressure Limit Low (mmHg) @param arterial_high: (int) Arterial Pressure Limit High (mmHg) @param venous_low: (int) Venous Pressure Limit Low (mmHg) @param venous_high: (int) Venous Pressure Limit High (mmHg) @return: none """ test.startSection("Verifying Arterial low and high " + "and Venous low and high value on main treatment screen") if accepted==ACCEPTED: arterial_low = waitForObject(names.pressure_text_obj(text=art_low)) arterial_low = arterial_low.text.toInt() arterial_high = waitForObject(names.pressure_text_obj(text=art_high)) arterial_high = arterial_high.text.toInt() venous_low = waitForObject(names.pressure_text_obj(text=ven_low)) venous_low = venous_low.text.toInt() venous_high = waitForObject(names.pressure_text_obj(text=ven_high)) venous_high = venous_high.text.toInt() test.compare(arterial_low, art_low, "Arterial low value should be " + "'{low_val}'".format(low_val=art_low)) test.compare(arterial_high, art_high, "Arterial high value should be " + "'{high_val}'".format(high_val=art_high)) test.compare(venous_low, ven_low, "Venous low value should be " + "'{low_val}'".format(low_val=ven_low)) test.compare(venous_high, ven_high, "Venous high value should not be " + "'{high_val}'".format(high_val=ven_high)) elif accepted==REJECTED: if object.exists(names.pressure_text_obj(text=art_low)): test.fail("{art_low} should not exists".format(art_low=art_low)) if object.exists(names.pressure_text_obj(text=art_high)): test.fail("{art_high} should not exists".format(art_high=art_high)) if object.exists(names.pressure_text_obj(text=ven_low)): test.fail("{ven_low} should not exists".format(ven_low=ven_low)) if object.exists(names.pressure_text_obj(text=ven_high)): test.fail("{ven_high} should not exists".format(ven_high=ven_high)) test.endSection() def verify_the_constants(): """ Method to open the pressure pop up and verify the arterial and venous scale minimum and maximum range value """ test.startSection("Open the pressure pop up and verify " + "the arterial and venous scale minimum and maximum range value") open_pressure_pop_up() arterial_scale = waitForObject(names.o_arterial_range_slider) 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, "Arterial scale range minimum value should be " + "{min}".format(min=ARTERIAL_PRESSURE_MINIMUM)) test.log("Verifying Arterial scale range maximum value") test.compare(arterial_scale_max, ARTERIAL_PRESSURE_MAXIMUM, "Arterial scale range maximum value should be " + "{max}".format(max=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, "Venous scale range minimum value should be " + "{min}".format(min=VENOUS_PRESSURE_MINIMUM)) test.log("Verifying Arterial scale range maximum value") test.compare(venous_scale_max, VENOUS_PRESSURE_MAXIMUM, "Venous scale range maximum value should be " + "{max}".format(max=VENOUS_PRESSURE_MAXIMUM)) test.log("Closing pressure pop up") mouseClick(waitForObjectExists(names.o_uf_close_button)) test.endSection() def verify_arterial_and_venous_value_on_pressure_pop_up(accepted, reason_id, art_low, art_high, ven_low, ven_high): """ Method to verify Arterial low and high and Venous low and high value on main treatment screen @param accepted: (int) boolean accept/reject response @param reason_id: (int) rejection reason id @param arterial_low: (int) Arterial Pressure Limit Low (mmHg) @param arterial_high: (int) Arterial Pressure Limit High (mmHg) @param venous_low: (int) Venous Pressure Limit Low (mmHg) @param venous_high: (int) Venous Pressure Limit High (mmHg) @return: none """ test.startSection("Verifying Arterial low and high " + "and Venous low and high value on pressure pop up screen") arterial_low = waitForObject(names.pressure_pop_up_text_obj(text=art_low)) arterial_low = arterial_low.text.toInt() arterial_high = waitForObject(names.pressure_pop_up_text_obj(text=art_high)) arterial_high = arterial_high.text.toInt() venous_low = waitForObject(names.pressure_pop_up_text_obj(text=ven_low)) venous_low = venous_low.text.toInt() venous_high = waitForObject(names.pressure_pop_up_text_obj(text=ven_high)) venous_high = venous_high.text.toInt() if accepted==ACCEPTED: test.compare(arterial_low, art_low, "Arterial low value should be " + "'{low_val}'".format(low_val=art_low)) test.compare(arterial_high, art_high, "Arterial high value should be " + "'{high_val}'".format(high_val=art_high)) test.compare(venous_low, ven_low, "Venous low value should be " + "'{low_val}'".format(low_val=ven_low)) test.compare(venous_high, ven_high, "Venous high value should be " + "'{high_val}'".format(high_val=ven_high)) elif accepted==REJECTED: if object.exists(names.pressure_text_obj(text=art_low)): test.fail("{art_low} should not exists".format(art_low=art_low)) if object.exists(names.pressure_text_obj(text=art_high)): test.fail("{art_high} should not exists".format(art_high=art_high)) if object.exists(names.pressure_text_obj(text=ven_low)): test.fail("{ven_low} should not exists".format(ven_low=ven_low)) if object.exists(names.pressure_text_obj(text=ven_high)): test.fail("{ven_high} should not exists".format(ven_low=ven_high)) verify_reject_msg_on_pop_up(reason_id) test.endSection() def set_arterial_and_venous_pressure(accepted, reason, \ art_low, art_high, ven_low, ven_high): """ Method to set the Arterial and Venous high and low pressure value @param accepted: (int) boolean accept/reject response @param reason: (int) rejection reason @param arterial_low: (int) Arterial Pressure Limit Low (mmHg) @param arterial_high: (int) Arterial Pressure Limit High (mmHg) @param venous_low: (int) Venous Pressure Limit Low (mmHg) @param venous_high: (int) Venous Pressure Limit High (mmHg) @return: none """ test.startSection("Set Arterial Low to '{art_low}' ".format(art_low=art_low) + "Arterial High to '{art_high}' ".format(art_high=art_high) + "Venous Low to '{ven_low}' ".format(ven_low=ven_low) + "and Venous High to '{ven_high}'".format(ven_high=ven_high)) hd.cmd_send_treatment_adjust_pressures_limit_response(accepted=accepted, reason=reason, arterial_low=art_low, arterial_high=art_high, venous_low=ven_low, venous_high=ven_high) test.endSection() def open_pressure_pop_up(): """ Method to open the pressure pop up and verify pop is opened """ test.startSection("Open 'Pressure' pop up") utils.waitForGUI(delay_s=2) pressure_touch_area = object.parent(waitForObjectExists(names.o_arterial_title)) mouseClick(pressure_touch_area) test.log("Verifying 'pressure' pop up is opened") test.log("Verifying 'Pressure' title") pressure_title = waitForObject(names.pressure_pop_up_text_obj(\ text=PRESSURE_TITLE)) pressure_title = pressure_title.text.toUtf8().constData() test.compare(pressure_title, PRESSURE_TITLE, "Pressure title should be '{title}'".format(title=PRESSURE_TITLE)) arterial_title = waitForObject(names.pressure_pop_up_text_obj(\ text=ARTERIAL_TITLE)) arterial_title = arterial_title.text.toUtf8().constData() test.compare(arterial_title, ARTERIAL_TITLE, "Arterial title should be '{title}'".format(title=ARTERIAL_TITLE)) art_uom = waitForObject(names.pressure_pop_up_text_obj(\ text=ARTERIAL_UOM)) art_uom = art_uom.text.toUtf8().constData() test.compare(art_uom, ARTERIAL_UOM, "Arterial unit of measurement should be " + "'{uom}'".format(uom=ARTERIAL_UOM)) venous_title = waitForObject(names.pressure_pop_up_text_obj(\ text=VENOUS_TITLE)) venous_title = venous_title.text.toUtf8().constData() test.compare(venous_title, VENOUS_TITLE, "Venous title should be '{title}'".format(title=VENOUS_TITLE)) ven_uom = waitForObject(names.pressure_pop_up_text_obj(\ text=VENOUS_UOM)) ven_uom = ven_uom.text.toUtf8().constData() test.compare(ven_uom, VENOUS_UOM, "Venous unit of measurement should be " + "'{uom}'".format(uom=VENOUS_UOM)) test.endSection() def verify_reject_msg_on_pop_up(reason_id): """ Method verify the rejection message on pop up screen """ test.startSection("Verify the rejection message " + "on pop up screen") reason_msg = waitForObject(names.o_pop_up_rejected_msg) reason_msg = reason_msg.text.toUtf8().constData() test.compare(reason_msg, REJECTION_REASON[reason_id], "{reason} should display on ".format(reason=REJECTION_REASON[reason_id]) + "on pop up when values are rejected") test.endSection() def verify_pressures_on_treatment_and_pop_up_screen(accepted=None, reason=None, art_low=None, art_high=None, ven_low=None, ven_high=None): """ Method to 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 """ 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, 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(delay_s=3) 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) test.endSection() def main(): utils.tstStart(__file__) start_application(AUT_NAME) hd.cmd_send_power_on_self_test_version_request() hd.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) verify_the_constants() 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_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) 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() hd.cmd_send_treatment_adjust_pressures_limit_response(accepted=ACCEPTED, reason=0, arterial_low=-301, arterial_high=201, venous_low=-101, venous_high=601) snooze(5)