# -*- 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_Treatment_Adjustment_Saline # date 2020/08/10 # author Behrouz NematiPour # import names from dialin.squish import utils, denaliMessages from dialin.squish.denaliMessages import txStates from dialin.common.msg_defs import RequestRejectReasons as rejectReason def gotoScreenNtest_Contains_TreatmentSalineBolusData(): mouseClick(waitForObject(names.o_treatmentHome_startTreatment)) test.compare(str(waitForObjectExists(names.o_treatmentStart_SalineSection).buttonText), "START BOLUS") test.compare(str(waitForObjectExists(names.o_treatmentStart_SalineSection).title ), "SALINE BOLUS") test.compare( waitForObjectExists(names.o_treatmentStart_SalineSection).visible , True) utils.waitForGUI(1) def getUnit(): return str(waitForObjectExists(names.o_treatmentStart_SalineSection).unit) def test_target(vTarget): test.compare( waitForObjectExists(names.o_treatmentStart_SalineSection).valueTarget , vTarget ) test.compare(str(waitForObjectExists(names.o_treatmentStart_SalineTarget ).text) , "({:.0f} {})".format(vTarget, getUnit())) def test_state(vAccept, vText, vState): mReason = 0 if (not vAccept): mReason = rejectReason.REQUEST_REJECT_REASON_SALINE_BOLUS_IN_PROGRESS.value mouseClick(waitForObject(names.o_treatmentStart_SalineStart)) # when rejected reason set 16 # although rejected value has been sent to check UI only looks for Accept field # value and reason are not related by added those two to have a different value in case of rejection target = 50 + mReason denaliMessages.setSalineBolusResponse(vAccept, mReason, target, vState) test.compare(str(waitForObjectExists(names.o_treatmentStart_SalineSection).buttonText), "{} BOLUS".format(vText)) test_target(target) def test_ultrafiltration_touchable(vEnabled): test.compare(waitForObjectExists(names.o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).isTouchable, vEnabled) def main(): utils.tstStart(__file__) startApplication(names.AUT_NAME) utils.waitForGUI(1) # Initial Idle -> Idle/START/UF_True gotoScreenNtest_Contains_TreatmentSalineBolusData() test_ultrafiltration_touchable(True ) # Initial Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" , txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True ) # retry Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" , txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True ) # Still Idle => Running => Accepted -> Running/STOP/UF_False test_state(True , "STOP" , txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) # Now Running => Idle => Rejected -> Running/STOP/UF_False test_state(False, "STOP" , txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) # Retry Running => Idle => Rejected -> Running/STOP/UF_False test_state(False, "STOP" , txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) # Still Running => Idle => Accepted -> Idle/START/UF_True test_state(True , "START" , txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True ) # Now Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" , txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True ) # Retry Idle => Running => Rejected -> Idle/START/UF_True test_state(False, "START" , txStates.SALINE_BOLUS_STATE_IDLE ) test_ultrafiltration_touchable(True ) # Still Idle => Running => Accepted -> Running/STOP/UF_False test_state(True , "STOP" , txStates.SALINE_BOLUS_STATE_IN_PROGRESS ) test_ultrafiltration_touchable(False) utils.tstDone()