# -*- 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_In_treatment # date 2020/01/11 # author Joseph Varghese. # # NOTE: # This test contradicts verification of saline bolus data and ultrafilteration(uf) of In-treatment # section import names import re from dialin.ui import utils from dialin.ui import unittests from dialin.ui.hd_simulator import HDSimulator from builtins import str as pyStr from configuration import utility, config UF_MINIMUM_VALUE = 0.000 UF_MAXIMUM_VALUE = 0.600 UF_DEFAULT_VALUE = 0.000 SALINE_BOLUS_TARGET = [0, 25, 30, 50, 100, 70, 220, 300] SALINE_BOLUS_CUMULATIVE = [0, 150, 180, 25, 35, 88, 180, 280] SALINE_BOLUS_DELIVERED = [0, 220, 852, 98, 758, 862, 752, 564] SALINE_BOLUS_DPI2BLDVolML = [0, 10.1, 15.5, 20.2, 16.5, 12.4, 21.3, 24.0] SALINE_BOLUS_RSRVR2DPIVolML = [0, 10,1, 20.2, 30.3, 40.4, 50.5, 60.6, 70.7] SALINE_BOLUS_zeroingRqstStatus = [0, 1, 2, 1, 0, 1, 2, 1] def verification_of_blood_prime_from_dialysis_state(): """ Tests for verification of blood prime UI section. @return: N/A """ blood_priming_page = waitForObject(names.o_blood_priming) blood_priming_text = blood_priming_page.text test.compare(blood_priming_text, config.BLOOD_PRIMING_TEXT) blood_priming_value = waitForObject(names.o_blood_priming_value_by_default) blood_priming_text = blood_priming_value.text test.compare(blood_priming_text, config.BLOOD_PRIMING_DEFAULT_VALUE) def verification_of_uf_from_dialysis_state(): """ Tests to verify components of ultrafilteration from dialysis section. @return: N/A """ uf_minimum = waitForObject(names.o_uf_minimum_value) uf_minimum_value = uf_minimum.text test.compare(format(UF_MINIMUM_VALUE, ".3f"), uf_minimum_value) uf_maximum = waitForObject(names.o_uf_maximum_value) uf_maximum_value = uf_maximum.text test.compare(format(UF_MAXIMUM_VALUE,".3f"), uf_maximum_value) def verification_of_target_value(expected_target_value): """ Tests to verify target values from saline bolus section. @input: expected target value. """ saline_value = waitForObject(names.o_fluid_text) saline_target = object.children(saline_value)[0] target_value = saline_target.text target_value_displayed = re.findall(r'\d+', pyStr(target_value)) test.compare(pyStr(expected_target_value), pyStr(target_value_displayed[0])) def verification_of_cumulative_value(expected_cumulative_value): """ Tests to verify cumulative values from saline bolus section. @input: expected cumulative value. """ saline_text = waitForObject(names.o_cumulative_fluid_text) saline_unit = object.children(saline_text)[0] if saline_unit.text == config.LIQUID_UNIT: saline_cumulative = object.children(saline_text)[1] test.compare(pyStr(float(expected_cumulative_value)), pyStr(saline_cumulative.text)) else: test.fail("Deviation observed in unit of saline (fluid)") def verification_of_delivered_value(expected_delivered_value): """ Tests to verify delivered values from saline bolus section. @input: expected delivered value. """ saline_text = waitForObject(names.o_fluid_text) saline_unit = object.children(saline_text)[1] if saline_unit.text == config.LIQUID_UNIT: saline_cumulative = object.children(saline_text)[2] test.compare(pyStr(float(expected_delivered_value)), pyStr(saline_cumulative.text)) else: test.fail("Deviation observed in unit of saline (fluid)") def verification_of_uf_pop_up(): """ Tests to verify ultrafilter pop-up UI section. @return: N/A """ #user clicks on ultra filteration section uf_maximum = waitForObject(names.o_uf_maximum_value) mouseClick(uf_maximum) utils.waitForGUI(0.5) uf_minimum = waitForObject(names.o_uf_minimum_value_pop_up) uf_minimum_value = uf_minimum.text test.compare(format(UF_MINIMUM_VALUE, ".3f"), uf_minimum_value) test.log("Uf minimum value should be "+format(UF_MINIMUM_VALUE,'.3f')) uf_maximum = waitForObject(names.o_uf_maximum_value_pop_up) uf_maximum_value = uf_maximum.text test.compare(format(UF_MAXIMUM_VALUE,".3f"), uf_maximum_value) test.log("Uf maximum value should be "+format(UF_MAXIMUM_VALUE,'.3f')) tapObject(waitForObject(names.o_edit_uf_value)) uf_maximum_displayed = waitForObject(names.o_uf_maximum_value) test.compare(format(UF_MAXIMUM_VALUE,".3f"), uf_maximum_displayed.text) test.log("Uf maximum value displayed on uf_edit section should be " +\ format(UF_MAXIMUM_VALUE,'.3f')+" by default") utils.waitForGUI(1) tapObject(waitForObject(names.o_uf_back_button)) tapObject(waitForObject(names.o_uf_close_button)) def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) hd = HDSimulator() unittests.test_python_version() hd.cmd_send_power_on_self_test_version_request() #navigate to blood prime state utils.waitForGUI(2) hd.cmd_send_hd_operation_mode(6, 0) verification_of_blood_prime_from_dialysis_state() utils.waitForGUI(2) #navigate to dialysis state 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, dialysis_state=0, bloodLeakZeoringState=0) verification_of_uf_from_dialysis_state() verification_of_uf_pop_up() hd.cmd_send_uf_treatment_response(accepted = 1, reason = 0, volume = 0.300) utils.waitForGUI(2) for index in range(8): target_value = SALINE_BOLUS_TARGET[index] cumulative_value = SALINE_BOLUS_CUMULATIVE[index] delivered_value = SALINE_BOLUS_DELIVERED[index] DPI2BLDVolML_value = SALINE_BOLUS_DPI2BLDVolML[index] RSRVR2DPIVolML_value = SALINE_BOLUS_RSRVR2DPIVolML[index] zeroingRqstStatus_value = SALINE_BOLUS_zeroingRqstStatus[index] hd.cmd_set_treatment_saline_bolus_data(target = target_value, cumulative = cumulative_value, delivered = delivered_value, DPI2BLDVolML = DPI2BLDVolML_value, RSRVR2DPIVolML = RSRVR2DPIVolML_value, zeroingRqstStatus = zeroingRqstStatus_value ) test.log("Verification of saline values from dialysis state for target value :" + str(target_value)+\ " cumulative value :" +str(cumulative_value)+" and delivered value :"+ str(delivered_value)) verification_of_target_value(expected_target_value = target_value) utils.waitForGUI(0.5) verification_of_delivered_value(expected_delivered_value = delivered_value) utils.waitForGUI(0.5) verification_of_cumulative_value(expected_cumulative_value = cumulative_value) utils.waitForGUI(0.5) utils.tstDone()