Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r294e8182b09559871bbb41e3792b14489b603047 -r2d57ccb6d19e9fda0a30ee78e25a4aea0414ff97 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 294e8182b09559871bbb41e3792b14489b603047) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 2d57ccb6d19e9fda0a30ee78e25a4aea0414ff97) @@ -1,34 +1,5 @@ -########################################################################### -# -# Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. -# -# 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 utils.py - -# @author (last) LTTS -# @date (last) 15-Jan-2022 -# -############################################################################ -import csv -import glob -import names -import object import squish -import shutil -import test -import re -import builtins -from builtins import format -from builtins import str as pyStr -from builtins import int as pyInt -from leahi_dialin.ui import utils -from leahi_dialin.utils import * -from datetime import timezone -from datetime import datetime - def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ To get an object with try..except catching to prevent script errors when the object is not found on the GUI @@ -40,8 +11,4 @@ except LookupError: test.fail("ERROR : " + error_message) return None - -def pressure_text_obj(text): - names.pressure_text_obj["text"] = text - return names.pressure_text_obj \ No newline at end of file Index: suite_leahi/shared/scripts/names.py =================================================================== diff -u -r499efbd537dd868fdc0e3e55057faae002d7161a -r2d57ccb6d19e9fda0a30ee78e25a4aea0414ff97 --- suite_leahi/shared/scripts/names.py (.../names.py) (revision 499efbd537dd868fdc0e3e55057faae002d7161a) +++ suite_leahi/shared/scripts/names.py (.../names.py) (revision 2d57ccb6d19e9fda0a30ee78e25a4aea0414ff97) @@ -2,59 +2,36 @@ from objectmaphelper import * -# AUT_NAME = "leahiSquish" -AUT_DEBUG = "leahi" - - -# # Top Parents -o_Gui_MainView = {"type": "Gui::MainView", "unnamed": 1} -o_QQuickView = { "type": "QQuickView"} -o_Overlay = {"container": o_QQuickView, "type": "Overlay"} -o_treatmentHome = {"container": o_QQuickView , "id": "_treatmentHome", "type": "TreatmentHome", "unnamed": 1} - -standByScreen_MainHome = {"container": o_Gui_MainView,"type": "MainHome","visible": True} -treatmentStack = {"container": o_Gui_MainView,"type": "TreatmentStack", "visible": True} -startTreatmentButton = {"container": standByScreen_MainHome, "id": "_startTreatmentRect","type": "TouchRect","unnamed": 1} -mainTreatmentScreen = {"container": treatmentStack, "id": "_treatmentHome", "type": "TreatmentHome","unnamed": 1} -startFluidButton = {"container": mainTreatmentScreen, "id": "_startFluidButton", "type": "TouchRect", "unnamed": 1 } -salineDeliveredText = {"container": mainTreatmentScreen, "objectName": "salineDescriptionText", "type": "Text" } -currentBolusVolume = {"container": mainTreatmentScreen, "type": "Label", "unnamed": 1 } -treatmentSaline = {"container": mainTreatmentScreen, "objectName": "treatmentSaline", "type": "TreatmentSaline" } -salineProgressBar = {"container": mainTreatmentScreen, "id": "_fluidProgressBar", "type": "ProgressBar", "unnamed": 1 } - -#treatment screen - pressures -mainTreatmentScreen_arterialRangeBar_RangeBar = {"container": mainTreatmentScreen, "id": "_arterialRangeBar", "type": "RangeBar", "unnamed": 1} -mainTreatmentScreen_arterialRangeBar_RangeBar_marker = {"container": mainTreatmentScreen, "id": "_rangeBar", "type": "RangeBar", "unnamed": 1} -mainTreatmentScreen_venousRangeBar_RangeBar = {"container": mainTreatmentScreen, "id": "_venousRangeBar", "type": "RangeBar", "unnamed": 1} -mainTreatmentScreen_venousRangeBar_RangeBar_marker = {"container": mainTreatmentScreen, "id": "_rangeBar", "type": "RangeBar", "unnamed": 1} -pressure_venous_marker_text = {"container": mainTreatmentScreen, "id": "_rangeMarkerValue", "occurrence": 2, "type": "RangeMarker", "unnamed": 1} -mainTreatmentScreen_tempRangeBar_RangeBar = {"container": mainTreatmentScreen, "id": "_venousRangeBar", "type": "RangeBar", "unnamed": 1} -mainTreatmentScreen_tempRangeBar_RangeBar_marker = {"container": mainTreatmentScreen, "id": "_rangeBar", "type": "RangeBar", "unnamed": 1} -pressure_temp_marker_text = {"container": mainTreatmentScreen, "id": "_rangeMarkerValue", "occurrence": 3, "type": "RangeMarker", "unnamed": 1} -arterial_RangeBar = {"container": mainTreatmentScreen, "id": "_rangeBar", "type": "RangeBar", "unnamed": 1} -venous_rangeBar = {"container": mainTreatmentScreen, "id": "_rangeBar", "occurrence": 2, "type": "RangeBar", "unnamed": 1} -temp_rangeBar = {"container": mainTreatmentScreen, "id": "_rangeBar", "occurrence": 3, "type": "RangeBar", "unnamed": 1} -pressure_text_obj = {"container": mainTreatmentScreen, "type": "Text", "unnamed": 1,"visible": True} -treatmentUltrafiltration = {"container": mainTreatmentScreen, "objectName": "treatmentUltrafiltration", "type": "TreatmentUltrafiltration"} -UF_Volume_Text = {"container": mainTreatmentScreen, "text": "UF Volume","type": "Text", "unnamed": 1} -UF_Rate_Text = {"container": mainTreatmentScreen, "text": "UF Rate", "type": "Text", "unnamed": 1} -treatment_duration = {"container": mainTreatmentScreen, "objectName": "treatmentTime", "type": "TreatmentTime"} - -UF_Volume_LabelValue = {"container": mainTreatmentScreen, "id": "_ufVolume","type": "LabelValue", "unnamed": 1} -UF_Rate_LabelValue = {"container": mainTreatmentScreen, "id": "_ufRate","type": "LabelValue", "unnamed": 1} -Volume_Delivered = {"container": mainTreatmentScreen, "id": "_valueText", "type": "Text", "unnamed": 1} - -blood_flow_value = {"container": mainTreatmentScreen, "objectName": "bloodFlowComponent", "type": "TreatmentFlowsComponent", "id": "_bloodFlow"} -dial_flow_value = {"container": mainTreatmentScreen, "objectName": "dialysateFlowComponent", "type": "TreatmentFlowsComponent", "id": "_dialysateFlow"} -dial_temp_value = {"container": mainTreatmentScreen, "objectName": "dialysateTempComponent", "type": "TreatmentFlowsComponent", "id": "_dialysateTemp"} -dial_cond_value = {"container": mainTreatmentScreen, "objectName": "dialysateCondComponent", "type": "TreatmentFlowsComponent", "id": "_dialysateCond"} -Treatment_Parameters_Text = {"container": mainTreatmentScreen, "text": "Treatment Parameters", "type": "Text", "unnamed": 1} -pressure_arterial_marker_text = {"container": mainTreatmentScreen, "id": "_rangeMarkerValue", "type": "RangeMarker", "unnamed": 1} -blood_flow_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "type": "Text", "text": "Blood Flow"} -dialyste_flow_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "type": "Text", "text": "Dialysate Flow"} -dialyste_temp_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "type": "Text", "text": "Dialysate Temp."} -dialyste_cond_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "type": "Text", "text": "Dialysate Cond."} - - - - +# Top Parents +o_Gui_MainView = { "type": "Gui::MainView", "unnamed": 1 } +standByScreen_MainHome = {"container": o_Gui_MainView, "type": "MainHome" } +treatmentStack = {"container": o_Gui_MainView, "type": "TreatmentStack" } +startTreatmentButton = {"container": o_Gui_MainView, "id": "_startTreatmentRect", "type": "TouchRect", "unnamed": 1 } +mainTreatmentScreen = {"container": treatmentStack, "id": "_treatmentHome", "type": "TreatmentHome", "unnamed": 1 } +startFluidButton = {"container": mainTreatmentScreen, "id": "_startFluidButton", "type": "TouchRect", "unnamed": 1 } +salineDeliveredText = {"container": mainTreatmentScreen, "objectName": "salineDescriptionText", "type": "Text" } +currentBolusVolume = {"container": mainTreatmentScreen, "type": "Label", "unnamed": 1 } +treatmentSaline = {"container": mainTreatmentScreen, "objectName": "treatmentSaline", "type": "TreatmentSaline" } +salineProgressBar = {"container": mainTreatmentScreen, "id": "_fluidProgressBar", "type": "ProgressBar", "unnamed": 1 } +pressure_venous_marker_text = {"container": mainTreatmentScreen, "id": "_rangeMarkerValue", "occurrence": 2, "type": "RangeMarker", "unnamed": 1 } +pressure_tmp_marker_text = {"container": mainTreatmentScreen, "id": "_rangeMarkerValue", "occurrence": 3, "type": "RangeMarker", "unnamed": 1 } +arterial_RangeBar = {"container": mainTreatmentScreen, "id": "_rangeBar", "type": "RangeBar", "unnamed": 1 } +venous_RangeBar = {"container": mainTreatmentScreen, "id": "_rangeBar", "occurrence": 2, "type": "RangeBar", "unnamed": 1 } +tmp_RangeBar = {"container": mainTreatmentScreen, "id": "_rangeBar", "occurrence": 3, "type": "RangeBar", "unnamed": 1 } +treatmentUltrafiltration = {"container": mainTreatmentScreen, "objectName": "treatmentUltrafiltration", "type": "TreatmentUltrafiltration"} +UF_Volume_Text = {"container": mainTreatmentScreen, "text": "UF Volume", "type": "Text", "unnamed": 1 } +UF_Rate_Text = {"container": mainTreatmentScreen, "text": "UF Rate", "type": "Text", "unnamed": 1 } +treatment_duration = {"container": mainTreatmentScreen, "objectName": "treatmentTime", "type": "TreatmentTime"} +UF_Volume_LabelValue = {"container": mainTreatmentScreen, "id": "_ufVolume", "type": "LabelValue", "unnamed": 1 } +UF_Rate_LabelValue = {"container": mainTreatmentScreen, "id": "_ufRate", "type": "LabelValue", "unnamed": 1 } +Volume_Delivered = {"container": mainTreatmentScreen, "id": "_valueText", "type": "Text", "unnamed": 1 } +blood_flow_value = {"container": mainTreatmentScreen, "id": "_bloodFlow", "objectName": "bloodFlowComponent", "type": "TreatmentFlowsComponent" } +dial_flow_value = {"container": mainTreatmentScreen, "objectName": "dialysateFlowComponent", "type": "TreatmentFlowsComponent" } +dial_tmp_value = {"container": mainTreatmentScreen, "id": "_dialysateTemp", "objectName": "dialysateTempComponent", "type": "TreatmentFlowsComponent" } +dial_cond_value = {"container": mainTreatmentScreen, "id": "_dialysateCond", "objectName": "dialysateCondComponent", "type": "TreatmentFlowsComponent" } +Treatment_Parameters_Text = {"container": mainTreatmentScreen, "text": "Treatment Parameters", "type": "Text", "unnamed": 1 } +pressure_arterial_marker_text = {"container": mainTreatmentScreen, "id": "_rangeMarkerValue", "type": "RangeMarker", "unnamed": 1 } +blood_flow_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "text": "Blood Flow" , "type": "Text", } +dialyste_flow_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "text": "Dialysate Flow", "type": "Text", } +dialyste_tmp_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "text": "Dialysate Temp." , "type": "Text", } +dialyste_cond_title_Text = {"container": mainTreatmentScreen, "objectName": "title", "text": "Dialysate Cond." , "type": "Text", } Index: suite_leahi/tst_main_treatment/test.py =================================================================== diff -u --- suite_leahi/tst_main_treatment/test.py (revision 0) +++ suite_leahi/tst_main_treatment/test.py (revision 2d57ccb6d19e9fda0a30ee78e25a4aea0414ff97) @@ -0,0 +1,332 @@ +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() +