# -*- coding: utf-8 -*- ########################################################################### # # Copyright (c) 2020-2023 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 test.py # # @author (last) Peter Lucia # @date (last) 29-Dec-2020 # @author (original) Behrouz NemaiPour # @date (original) 06-Aug-2020 # ############################################################################ import os from time import sleep import names from dialin.ui import utils from dialin import HDSimulator from dialin.ui.hd_simulator_alarms import (Alarms, NONE, LOW, MED, HIGH, HIGH_PRIORITY_COLOR, MED_LOW_PRIORITY_COLOR) from typing import List def test_alarms(hd_simulator:HDSimulator, alarms:Alarms, alarm_list: List[Alarms], skip_hd_timeout: bool = True): """ Tests a list of alarm tuples. @param hd_simulator: The HD Simulator object @param alarms: Alarm class object @param alarms_list: list of alarm tuples to test. @param skip_timeout: whether to skip the hd comm timeout error, default = False @return: None """ for idx, (priority, alarm_id, escalates_in, silent_expires_in, flags) in enumerate(alarm_list): if (alarm_list[idx] == alarms.ALARM_ID_NO_ALARM): continue if (alarm_list[idx] == alarms.ALARM_ID_HD_COMM_TIMEOUT) and skip_hd_timeout: continue #test.log("Testing {0} = {1}".format(alarm_list[idx], alarm_id)) color = HIGH_PRIORITY_COLOR if priority == HIGH else MED_LOW_PRIORITY_COLOR flags = hd_simulator.alarms_simulator.cmd_make_alarm_flags( no_clear=1, no_resume=1, no_rinseback=1, no_end_treatment=1, no_new_treatment=1, user_must_ack=1) hd_simulator.alarms_simulator.cmd_activate_alarm_id(priority, alarm_id, escalates_in, silent_expires_in, flags) test.compare(waitForObject(names.o_alarm_dialog).color.name, color) mouseClick(waitForObject(names.o_okay_alarm)) hd_simulator.alarms_simulator.cmd_send_clear_alarms() def get_alarm_list(alarms): """ Gets the alarm list @return: The alarms (list of tuples) """ alarm_list = [] for attr in dir(alarms): if not callable(getattr(alarms, attr)) and attr.startswith("ALARM_ID"): alarm_list.append(getattr(alarms, attr)) return sorted(alarm_list, key = lambda val: val [1]) def main(): """ Main function to test the alarms. @return: None """ utils.tstStart(__file__) hd_simulator = HDSimulator() startApplication(names.AUT_NAME + " -q") alarms = Alarms() alarm_list = get_alarm_list(alarms) test_alarms(hd_simulator, alarms, alarm_list) os.system("killall " + names.AUT_NAME) sleep(3) startApplication(names.AUT_NAME) alarm_list = [alarms.ALARM_ID_HD_COMM_TIMEOUT] # test hd comm timeout since it was skipped in the last test test_alarms(hd_simulator, alarms, alarm_list, skip_hd_timeout = False) utils.tstDone()