# -*- 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 Apr/12/2022 # author Papiya Mandal import names from builtins import int as pyInt from configuration.config import * from configuration.utility import * from configuration import application_init from leahi_dialin.ui import utils from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.ui.dd_messaging import DD_Messaging from configuration import utility from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.common import msg_defs from leahi_dialin.common.td_defs import TDOpModes in_range_color = "#ffffff" out_of_range_color = "#c53b33" ART_LOW_VAL_MINUS_390 = -390 ART_HIGH_VAL_220 = 220 VENOUS_LOW_VAL_MINUS_90 = -90 VENOUS_HIGH_VAL_410 = 410 TEMP_LOW_VAL_MINUS_640 =-640 TEMP_HIGH_VAL_210 =210 REJECTED = 1 ACCEPTED = 0 # 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}, ] total_time_list = [90,120] uf_filtration = [ {"uf_volume": 1 ,"uf_rate": 0.53 ,"vol_delivered":0.37}, {"uf_volume": 10 ,"uf_rate": 5.05 ,"vol_delivered":2.37}, {"uf_volume": 20 ,"uf_rate": 10.0 ,"vol_delivered":5.0 }, {"uf_volume": 100 ,"uf_rate": 140.0 ,"vol_delivered":156.0 }, {"uf_volume": 0 ,"uf_rate": 0.0 ,"vol_delivered":0.0 } ] td =TD_Messaging() dd = DD_Messaging() def verify_arterial_and_venous_value_in_main_treatment_screen(accepted, art_low, art_high, ven_low, ven_high,temp_low,temp_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(pressure_text_obj(art_low)) arterial_low = arterial_low.text.toInt() arterial_high = waitForObject(pressure_text_obj(art_high)) arterial_high = arterial_high.text.toInt() venous_low = waitForObject(pressure_text_obj(ven_low)) venous_low = venous_low.text.toInt() venous_high = waitForObject(pressure_text_obj(ven_high)) venous_high = venous_high.text.toInt() temperature_low = waitForObject(pressure_text_obj(ven_low)) temperature_low = temperature_low.text.toInt() temperature_high = waitForObject(pressure_text_obj(ven_high)) temperature_high = temperature_high.text.toInt() test.compare(arterial_low, art_low, "Arterial low value should be '{}'".format(art_low)) test.compare(arterial_high, art_high, "Arterial high value should be '{}'".format(art_high)) test.compare(venous_low, ven_low, "Venous low value should be '{}'".format(ven_low)) test.compare(venous_high, ven_high, "Venous high value should not be '{}'".format(ven_high)) test.compare(venous_low, ven_low, "temperature low value should be '{}'".format(temp_low)) test.compare(venous_high, ven_high, "temperature high value should not be '{}'".format(temp_high)) else: if object.exists(pressure_text_obj(art_low)): test.fail("Arterial value {} should not exists".format(art_low)) if object.exists(pressure_text_obj(art_high)): test.fail("Arterial value {} should not exists".format(art_high)) if object.exists(pressure_text_obj(ven_low)): test.fail("Venous value {} should not exists".format(ven_low)) if object.exists(pressure_text_obj(ven_high)): test.fail("Venous value {} should not exists".format(ven_high)) if object.exists(pressure_text_obj(temp_low)): test.fail("Temperature value {} should not exists".format(temp_low)) if object.exists(pressure_text_obj(temp_high)): test.fail("Temperature value {} should not exists".format(temp_high)) test.endSection() def test_pressure_displayed_in_treatment_screen_range_bar(): TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES = [ { "arterial_pressure": 100, "arterial_limit_low":-300, "arterial_limit_high":120, "venous_pressure": 140, "venous_limit_low":-100, "venous_limit_high":250, "pressure_limit_state":2, "tmp_pressure":250 , "tmp_limit_low":-400 , "tmp_limit_high": 200 }, { "arterial_pressure": -200, "arterial_limit_low":-150, "arterial_limit_high":120, "venous_pressure": 140, "venous_limit_low":-100, "venous_limit_high":250, "pressure_limit_state":2, "tmp_pressure":200 , "tmp_limit_low":-300 , "tmp_limit_high": 200 }, { "arterial_pressure": 110, "arterial_limit_low":100, "arterial_limit_high":120, "venous_pressure": -100 , "venous_limit_low":-50, "venous_limit_high":250, "pressure_limit_state":2, "tmp_pressure":250 , "tmp_limit_low":-200 , "tmp_limit_high": 400 }, { "arterial_pressure": -130, "arterial_limit_low":-140, "arterial_limit_high":120, "venous_pressure": 200, "venous_limit_low":-100, "venous_limit_high":150, "pressure_limit_state":2, "tmp_pressure":250 , "tmp_limit_low":-100 , "tmp_limit_high": 600 }, ] 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"] target_temp_pressure = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["tmp_pressure"] target_temp_min_limit = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["tmp_limit_low"] target_temp_max_limit = TREATMENT_PRESSURE_ADJUSTMENT_HD_TEST_VALUES[index]["tmp_limit_high"] td.td_pressure( H2_arterial_pressure = target_arterial_pressure, H14_venous_pressure = target_venous_pressure , limit_state = target_pressure_state, H2_arterial_min = target_arterial_min_limit, H2_arterial_max = target_arterial_max_limit , H14_venous_min = target_venous_min_limit , H14_venous_max= target_venous_max_limit , H2_arterial_long= 0 , H14_venous_long= 0 , tmp_pressure= target_temp_pressure , tmp_min= target_temp_min_limit , tmp_max= target_temp_max_limit) utils.waitForGUI(1) # check the range bar's upper and lower bounds arterial_rangeBar = utility.get_object_from_names(names.arterial_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.pressure_arterial_marker_text, error_message="arterial pressure marker label object is missing") if arterial_rangeBar_marker_text_object is not None: actual_text = str(arterial_rangeBar_marker_text_object.text).strip() expected_text = str(target_arterial_pressure).strip() test.compare(actual_text, expected_text, "Expecting arterial pressure to be displayed") # check the range bar's upper and lower bounds venous_rangeBar = utility.get_object_from_names(names.venous_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.pressure_venous_marker_text, error_message="venous pressure marker label object is missing") if venous_rangeBar_marker_text_object is not None: actual_text = str(venous_rangeBar_marker_text_object.text).strip() expected_text = str(target_venous_pressure).strip() test.compare(actual_text, expected_text, "Expecting venous pressure to be displayed") # check the range bar's upper and lower bounds temp_rangeBar = utility.get_object_from_names(names.temp_rangeBar, error_message="venous rangeBar object is missing") if temp_rangeBar is not None: test.compare(temp_rangeBar.lowerBound, target_temp_min_limit, "Checking lower bound of temperature pressure range bar") test.compare(temp_rangeBar.upperBound, target_temp_max_limit, "Checking upper bound of temperature pressure range bar") #check the marker value for the tempreature pressure temp_rangeBar_marker_text_object = utility.get_object_from_names(names.pressure_temp_marker_text, error_message="venous pressure marker label object is missing") if temp_rangeBar_marker_text_object is not None: actual_text = str(temp_rangeBar_marker_text_object.text).strip() expected_text = str(target_temp_pressure).strip() test.compare(actual_text, expected_text, "Expecting temperature pressure to be displayed") utils.waitForGUI(1) test.endSection() #Ultrafiltration state def verification_of_uf_from_main_treatment(): """ @return: N/A """ test.compare(waitForObjectExists(names.treatmentUltrafiltration).visible, True, "ultrafiltration section is visible") test.compare(waitForObjectExists(names.UF_Volume_Text).text, "UF Volume", "UF Volume text verified") test.compare(waitForObjectExists(names.UF_Rate_Text).text, "UF Rate", "UF Rate text verified") def start_test_treatment_ultrafiltration(uf_volume,uf_rate,vol_delivered): """ Test slider movement of ultrafiltration volume. @param ultrafiltration_range: (dictionary) uf minimum and uf maximum volume. @param uf_state: (int) ultrafiltration state to be set. @return: N/A """ td.td_ultrafiltration(uf_volume,uf_rate,vol_delivered,0) test.compare(waitForObjectExists(names.UF_Volume_LabelValue).bottomText, "{:.2f}".format(float(uf_volume)), "UF Volume value should be :" + str(uf_volume)) test.compare(waitForObjectExists(names.UF_Rate_LabelValue).bottomText, "{:.2f}".format(float(uf_rate)), "UF Rate value should be :" + str(uf_rate)) test.compare(waitForObjectExists(names.Volume_Delivered).text, "{:.2f}".format(float(vol_delivered)) +" L", "Volume delivered value should be :" + str(vol_delivered)) #TX time def start_treatment_time_verification(vTotal): """ Method to verify Actual time in seconds to Time appear on UI Screen in seconds. Also it compare the Progress bar value in seconds @param vTotal: (int) Total time in seconds """ for count in range(0,vTotal+1): td.td_treatment_time(vTotal, count, vTotal - count) utils.waitForGUI(0.5) test.compare(waitForObjectExists(names.treatment_duration).progressValue, count, "progress value should be {}".format(count)) test.compare(waitForObjectExists(names.treatment_duration).timeTextValue, vTotal - count, "Expected Time on UI should be in seconds {}".format(vTotal - count)) def reset_treatment_time_verification(vTotal): """ Method to reset and verify Actual time in seconds to Maximum & Minimum values on UI screen in seconds @param vTotal: (int) Total time in seconds """ td.td_treatment_time(vTotal, 0, vTotal) test.compare(waitForObjectExists(names.treatment_duration).maximum, vTotal, "Reset maximum value and compare it expected value {}".format(vTotal)) test.compare(waitForObjectExists(names.treatment_duration).minimum, 0, "Reset minimum value and compare it expected value {}".format(0)) def treatment_time_verification(total): test.startSection("Verify the seconds values inside Progress bar and on timer 'Time in seconds'") reset_treatment_time_verification(total) start_treatment_time_verification(total) test.endSection() #Tx Parameter set points def verify_setPoints_from_main_treatement(): TREATMENT_PARAMETER_SETPOINTS_TD_TEST_VALUES = [ {"blood flow": 56, "dial flow":22, "dial temp":20.0,"dial cond":34.0}, {"blood flow": 99, "dial flow":78, "dial temp":87.0,"dial cond":55.0}, {"blood flow": 34, "dial flow":99, "dial temp":99.0,"dial cond":99.0}, {"blood flow": 100, "dial flow":100, "dial temp":100.0,"dial cond":100.0}, {"blood flow": 110, "dial flow":110, "dial temp":110.0,"dial cond":110.0} ] #Verify the tittle values in the set points test.compare(waitForObjectExists(names.Treatment_Parameters_Text).text, "Treatment Parameters", "Treatement Parameters text verified") for index in range(0, len(TREATMENT_PARAMETER_SETPOINTS_TD_TEST_VALUES), 1): test.startSection("Checking the value of the set points".format(index)) target_blood_flow = TREATMENT_PARAMETER_SETPOINTS_TD_TEST_VALUES[index]["blood flow"] target_dial_flow = TREATMENT_PARAMETER_SETPOINTS_TD_TEST_VALUES[index]["dial flow"] target_dial_temp = TREATMENT_PARAMETER_SETPOINTS_TD_TEST_VALUES[index]["dial temp"] target_dial_cond = TREATMENT_PARAMETER_SETPOINTS_TD_TEST_VALUES[index]["dial cond"] td.td_treatment_set_points( blood_flow =target_blood_flow, dialysate_flow = target_dial_flow, dialysate_temp =target_dial_temp) utils.waitForGUI(1) bloodFlow = waitForObject(names.blood_flow_value) bloodFlow_properties = object.properties(bloodFlow) test.compare(str(bloodFlow_properties["value"]), str(target_blood_flow), "Blood Flow value should be :" + str(target_blood_flow)) dialFlow = waitForObject(names.dial_flow_value) dialFlow_properties = object.properties(dialFlow) test.compare(str(dialFlow_properties["value"]), str(target_dial_flow), "Dialyste flow value should be :" + str(target_dial_flow)) dialTemp = waitForObject(names.dial_temp_value) dialTemp_properties = object.properties(dialTemp) test.compare(str(dialTemp_properties["value"]), str(target_dial_temp), "Dialyste Temp value should be :" + str(target_dial_temp)) dd.dd_conductivity(D17= 0, D27= 0, D29= target_dial_cond, D43= 0, D74= 0) dialCond = waitForObject(names.dial_cond_value) dialCond_properties = object.properties(dialCond) test.compare(str(dialCond_properties["value"]), str(target_dial_cond), "Dialyste conductivity value should be :" + str(target_dial_cond)) def main(): utils.tstStart(__file__) startApplication("leahi") # need to have acknowledging enabled td.td_operation_mode(TDOpModes.MODE_STAN.value) # verify Standby screen test.verify(waitForObjectExists(names.standByScreen_MainHome), "In Standby") mouseClick(waitForObject(names.startTreatmentButton)) # verify main treatment screen test.verify(waitForObjectExists(names.mainTreatmentScreen), "In Main Treatment") utils.waitForGUI(1) # Pressure State test_pressure_displayed_in_treatment_screen_range_bar() td.td_pressure( H2_arterial_pressure = 0, H14_venous_pressure = 0 , limit_state = 0, H2_arterial_min = ART_LOW_VAL_MINUS_390, H2_arterial_max = ART_HIGH_VAL_220 , H14_venous_min = VENOUS_LOW_VAL_MINUS_90 , H14_venous_max= VENOUS_HIGH_VAL_410 , H2_arterial_long= 0 , H14_venous_long= 0 , tmp_pressure= 0 , tmp_min= TEMP_LOW_VAL_MINUS_640 , tmp_max= TEMP_HIGH_VAL_210) # utils.waitForGUI(1) # verify_arterial_and_venous_value_in_main_treatment_screen(ACCEPTED,ART_LOW_VAL_MINUS_390,ART_HIGH_VAL_220,VENOUS_LOW_VAL_MINUS_90,VENOUS_HIGH_VAL_410,TEMP_LOW_VAL_MINUS_640,TEMP_HIGH_VAL_210) #Ultrafiltration state # navigate to dialysis state verification_of_uf_from_main_treatment() for value in uf_filtration: start_test_treatment_ultrafiltration(**value) #TX Time # Calculating total seconds into minutes and passing to treatment time verification for value in total_time_list: treatment_time_verification(value) #Tx Parameter Set Points verify_setPoints_from_main_treatement() utils.tstDone()