# -*- 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_time_duration # @author (last) Amol Shinde # @author (last) Sai Chaitanya Ela # @date (last) 04-03-2022 import names from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from configuration import config from random import randint MIN_TIME_RANGE = 60 MAX_TIME_RANGE = 480 hd_simulator = HDSimulator() 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 i in range(0,vTotal+1): hd_simulator.cmd_set_treatment_time(vTotal, i, vTotal - i) test.compare(waitForObjectExists(names.o_treatment_duration).progressValue, i, "progress value should be {}".format(i)) test.compare(waitForObjectExists(names.o_treatment_duration).timeTextValue, vTotal - i, "Expected Time on UI should be in seconds {}".format(vTotal - i)) 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 """ hd_simulator.cmd_set_treatment_time(vTotal, 0, vTotal) test.compare(waitForObjectExists(names.o_treatment_duration).maximum, vTotal, "Reset maximum value and compare it expected value {}".format(vTotal)) test.compare(waitForObjectExists(names.o_treatment_duration).minimum, 0, "Reset minimum value and compare it expected value {}".format(0)) def verify_pause_treatment_text(): """ Method to verify 'Treatment Paused' text is displayed """ test.log("Verifying the text 'Treatment Paused'") test.compare(str(waitForObjectExists(names.o_Treatment_Paused).text), config.TREATMENT_PAUSED_TEXT, "{} should display Main treatment's remain time section".format(config.TREATMENT_PAUSED_TEXT)) 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() def total_time(): """ Method for providing two random values between the time duration range as per SRSUI documents from 60 to 480 Minutes """ totaltime_list = [] id_count = 0 while id_count < 2: id = randint(MIN_TIME_RANGE, MAX_TIME_RANGE) if id in totaltime_list: pass else: totaltime_list.append(id) id_count += 1 test.log("Selected time are {}".format(totaltime_list)) return totaltime_list def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) #navigate to dialysis state hd_simulator.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) # hd_simulator.cmd_set_treatment_start_state() #Calculating total seconds into minutes and passing to treatment time verification total_time_list = total_time() for value in total_time_list: treatment_time_verification(value*60) #Give treatment stop response to pause remain time hd_simulator.cmd_set_treatment_states_data(sub_mode= 0, 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=1, dialysis_state=0) #verify treatment pause state verify_pause_treatment_text() #Send treatment start response after pause state hd_simulator.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) #Again start treatment for time verification mouseClick(waitForObject(names.o_treatmentHome_Time_Remaining_Text)) test.verify(waitForObjectExists(names.o_confirm_Text).enabled, "'Confirm' button should be enabled") #FIXME: If we not use specified value then it will take minimum one and maximum 8 hours. treatment_time_verification(60) utils.tstDone()