import names 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.td_defs import TDOpModes,TDTreatmentStates 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 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_rangeBar = utility.get_object_from_names(names.arterial_RangeBar, error_message="arterial rangeBar object is missing") arterial_low = arterial_rangeBar.lowerBound arterial_high = arterial_rangeBar.upperBound venous_rangeBar = utility.get_object_from_names(names.venous_RangeBar, error_message="venous rangeBar object is missing") venous_low = venous_rangeBar.lowerBound venous_high = venous_rangeBar.upperBound temp_rangeBar = utility.get_object_from_names(names.tmp_RangeBar, error_message="temperature rangeBar object is missing") temperature_low = temp_rangeBar.lowerBound temperature_high = temp_rangeBar.upperBound 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(temperature_low, temp_low, "temperature low value should be '{}'".format(temp_low)) test.compare(temperature_high, temp_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_TD_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_TD_TEST_VALUES), 1): test.startSection("Checking the value of the range bar in pressure on the treatment screen - dataset # {}".format(index)) target_arterial_pressure = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["arterial_pressure"] target_venous_pressure = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["venous_pressure"] target_pressure_state = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["pressure_limit_state"] target_arterial_min_limit = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["arterial_limit_low"] target_arterial_max_limit = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["arterial_limit_high"] target_venous_min_limit = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["venous_limit_low"] target_venous_max_limit = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["venous_limit_high"] target_temp_pressure = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["tmp_pressure"] target_temp_min_limit = TREATMENT_PRESSURE_ADJUSTMENT_TD_TEST_VALUES[index]["tmp_limit_low"] target_temp_max_limit = TREATMENT_PRESSURE_ADJUSTMENT_TD_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) # 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",timeout_ms=1000) 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",timeout_ms=1000) if arterial_rangeBar_marker_text_object is not None: actual_text = str(arterial_rangeBar_marker_text_object.value).strip() expected_text = str(target_arterial_pressure).strip() test.compare(float(actual_text), float(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",timeout_ms=1000) 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",timeout_ms=1000) if venous_rangeBar_marker_text_object is not None: actual_text = str(venous_rangeBar_marker_text_object.value).strip() expected_text = str(target_venous_pressure).strip() test.compare(float(actual_text), float(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.tmp_RangeBar, error_message="Temperature rangeBar object is missing",timeout_ms=1000) 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_tmp_marker_text, error_message="temperature pressure marker label object is missing",timeout_ms=1000) if temp_rangeBar_marker_text_object is not None: actual_text = str(temp_rangeBar_marker_text_object.value).strip() expected_text = str(target_temp_pressure).strip() test.compare(float(actual_text), float(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 title values in the set points test.compare(waitForObjectExists(names.Treatment_Parameters_Text).text, "Treatment Parameters", "Treatement Parameters text verified") test.compare(waitForObjectExists(names.blood_flow_title_Text).text, "Blood Flow", "Blood flow text verified" ) test.compare(waitForObjectExists(names.dialyste_flow_title_Text).text, "Dialysate Flow", "Dialysate Flow text verified" ) test.compare(waitForObjectExists(names.dialyste_tmp_title_Text).text, "Dialysate Temp.", "Dialysate temp text verified" ) test.compare(waitForObjectExists(names.dialyste_cond_title_Text).text, "Dialysate Cond.", "Dialysate cond 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_tmp_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") td.td_operation_mode(TDOpModes.MODE_STAN.value) # verify Standby screen test.verify(waitForObjectExists(names.standByScreen_MainHome), "In Standby") td.td_tx_state(TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0) # verify main treatment screen test.verify(waitForObjectExists(names.mainTreatmentScreen), "In Main Treatment") # 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) 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 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()