import names import squish import math import datetime import test import sys from time import sleep from dialin.ui import utils from dialin.ui import unittests from dialin.ui.hd_simulator import HDSimulator from builtins import str as pyStr from builtins import int as pyInt # from dialin.ui.dg_simulator import DGSimulator # from dialin.ui.hd_simulator_alarms import HDAlarmsSimulator GOODMORNING_START_TIME_SEC = 0 GOODEVENING_START_TIME_SEC = 43200 def get_current_time(): """ Tests to get current time. @return: current time in seconds """ now = datetime.datetime.now() current_time = now.strftime("%H:%M:%S") hours, minutes, seconds = current_time.split(':') time_in_seconds = datetime.timedelta(hours = pyInt(hours), minutes = pyInt(minutes), seconds = pyInt(seconds)) total_seconds = time_in_seconds.total_seconds() return total_seconds def verification_of_create_treatment_text(): """ Tests for verification of create treatment text. @return: N/A """ standby_text = waitForObject(names.standby_page) create_treatment = object.children(standby_text)[1] child = object.children(create_treatment)[1] test.compare(child.text, "CREATE TREATMENT") def verification_of_welcome_text_on_standby_mode(current_time): """ Tests to verify welcome text based on current time. @return: current time in seconds """ standby_text = waitForObject(names.standby_page) child = object.children(standby_text)[0] if current_time >= GOODMORNING_START_TIME_SEC and \ current_time <= GOODEVENING_START_TIME_SEC: test.compare(child.text, "Good Morning") else: test.compare(child.text, "Good Evening") def main(): utils.tstStart("demo") startApplication("denaliSquish") hd = HDSimulator() #dg = DGSimulator() hd.cmd_send_power_on_self_test_version_request() hd.cmd_send_hd_operation_mode(3) current_time = get_current_time() verification_of_welcome_text_on_standby_mode(current_time) sleep(0.5) verification_of_create_treatment_text() utils.tstDone() #sleep(10) #hd.logger.debug("Canceling treatment") #hd.cmd_send_hd_operation_mode(HDOpModes.MODE_STAN.value) #hd.logger.debug("Starting treatment") #hd.cmd_send_hd_operation_mode(HDOpModes.MODE_TREA.value) #hd.cmd_initiate_treatment_response(YES, 0) #hd.pre_treatment_on_selected_patient_id() # hd.cmd_send_hd_post(0, True, True) # hd.cmd_send_hd_operation_mode(4, 0) #hd.pre_treatment() #hd._handler_ui_pre_treatment_uf_request("6")