Fisheye: Tag 568e97ea04d6b8bd977bf3533980a42b26ec951e refers to a dead (removed) revision in file `shared/scripts/configuration/assertion_helper.py'. Fisheye: No comparison available. Pass `N' to diff? Index: shared/scripts/configuration/config.py =================================================================== diff -u -r27243911dd859b5a1b97d69637e108763f955cd4 -r568e97ea04d6b8bd977bf3533980a42b26ec951e --- shared/scripts/configuration/config.py (.../config.py) (revision 27243911dd859b5a1b97d69637e108763f955cd4) +++ shared/scripts/configuration/config.py (.../config.py) (revision 568e97ea04d6b8bd977bf3533980a42b26ec951e) @@ -165,8 +165,10 @@ 137: "HD tilt exceeds maximum." , 138: "DG tilt exceeds maximum.", 139: "HD AC power lost alarm." , - 140: "Dialysate generator communication timeout." , - 141: "Air trap fill timeout during treatment.", + 140: "Dialysate generator communication timeout." , + 141: "Air trap fill timeout during treatment.", + 142: "Blood pump occlusion detected.", + 143: "This alarm ID is available for use.", 144: "This alarm ID is available for use.", 145: "Concentrate conductivity after adding acid out of range alarm." , 146: "Dialysate conductivity out of range." , @@ -315,8 +317,52 @@ 289: "Total number of alarms.", } -ALARM_PRIORITY_NONE = 0 # Indicates not an alarm or no alarms active at this time -ALARM_PRIORITY_LOW = 1 # Low priority alarm -ALARM_PRIORITY_MEDIUM = 2 # Medium priority alarm -ALARM_PRIORITY_HIGH = 3 # High priority alarm -NUM_OF_ALARM_PRIORITIES = 4 # Total number of alarm priorities \ No newline at end of file +ALARM_PRIORITIES = {1: "LOW", 2: "MEDIUM", 3: "HIGH"} +NUM_OF_ALARM_PRIORITIES = 4 # Total number of alarm priorities +ACCEPTED = True +REJECTED = False +ALARM_LIST_TITLE = "Alarm list" + +REJECTION_REASON = { + 0: "No Active Alarm List", + 1: "REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE", + 2: "REQUEST_REJECT_REASON_TIMEOUT_WAITING_FOR_USER_CONFIRM", + 3: "REQUEST_REJECT_REASON_NOT_IN_TREATMENT_MODE", + 4: "REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE", + 5: "REQUEST_REJECT_REASON_TREATMENT_TOO_CLOSE_TO_FINISHED", + 6: "REQUEST_REJECT_REASON_TREATMENT_TIME_OUT_OF_RANGE", + 7: "REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_CURRENT", + 8: "REQUEST_REJECT_REASON_BLOOD_FLOW_OUT_OF_RANGE", + 9: "REQUEST_REJECT_REASON_DIAL_FLOW_OUT_OF_RANGE", + 10: "REQUEST_REJECT_REASON_DIAL_VOLUME_OUT_OF_RANGE", + 11: "REQUEST_REJECT_REASON_UF_VOLUME_OUT_OF_RANGE", + 12: "REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE", + 13: "REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_MINIMUM", + 14: "REQUEST_REJECT_REASON_UF_NOT_IN_PROGESS", + 15: "REQUEST_REJECT_REASON_UF_NOT_PAUSED", + 16: "REQUEST_REJECT_REASON_SALINE_BOLUS_IN_PROGRESS", + 17: "REQUEST_REJECT_REASON_PARAM_OUT_OF_RANGE", + 18: "REQUEST_REJECT_REASON_HEPARIN_PRESTOP_EXCEEDS_DURATION", + 19: "REQUEST_REJECT_REASON_ARTERIAL_PRESSURE_LOW_VS_HIGH", + 20: "REQUEST_REJECT_REASON_VENOUS_PRESSURE_LOW_VS_HIGH", + 21: "REQUEST_REJECT_REASON_SALINE_MAX_VOLUME_REACHED", + 22: "REQUEST_REJECT_REASON_SALINE_BOLUS_NOT_IN_PROGRESS", + 23: "REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE", + 24: "REQUEST_REJECT_REASON_ALARM_IS_ACTIVE", + 25: "REQUEST_REJECT_REASON_INVALID_COMMAND", + 26: "REQUEST_REJECT_REASON_TREATMENT_IS_COMPLETED", + 27: "REQUEST_REJECT_REASON_ADDL_RINSEBACK_MAX_VOLUME_REACHED", + 28: "REQUEST_REJECT_REASON_UF_VOLUME_NOT_SET", + 29: "REQUEST_REJECT_REASON_NO_PATIENT_CONNECTION_CONFIRM", + 30: "REQUEST_REJECT_REASON_HEPARIN_PAUSE_INVALID_IN_THIS_STATE", + 31: "REQUEST_REJECT_REASON_HEPARIN_NOT_PAUSED", + 32: "REQUEST_REJECT_REASON_DG_COMM_LOST", + 33: "REQUEST_REJECT_REASON_DRAIN_NOT_COMPLETE", + 34: "REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE", + 35: "REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT", + 36: "REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME", + 37: "REQUEST_REJECT_REASON_NO_NEW_TREATMENT_ALARM_TRIGGERED", + 38: "REQUEST_REJECT_REASON_BATTERY_IS_NOT_CHARGED", + 39: "REQUEST_REJECT_REASON_RINSEBACK_NOT_COMPLETED", + } + \ No newline at end of file Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r549e92960cbce36d7be3fc981fd41d99bf73e016 -r568e97ea04d6b8bd977bf3533980a42b26ec951e --- shared/scripts/configuration/utility.py (.../utility.py) (revision 549e92960cbce36d7be3fc981fd41d99bf73e016) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 568e97ea04d6b8bd977bf3533980a42b26ec951e) @@ -109,12 +109,12 @@ -def scroll_to_zone(zone=None, screen_object=None): +def scroll_to_zone(zone=None, screen_object=None, screen="Main"): """ scroll to the numeric if object is hidden Arguments: zone - UI object - screen_object - UI object (UI Home screen = waveforms + numerics) + screen_object - UI object Return: bool """ @@ -132,8 +132,12 @@ ScreenObj = squish.waitForObject(screen_object) screenHeight = pyInt(ScreenObj.height) screenWidth = pyInt(ScreenObj.width) - squish.mouseWheel(ScreenObj, screenWidth-1000, - screenHeight-10, 0, -50, squish.Qt.NoModifier) + if screen == "pop up": + squish.mouseWheel(ScreenObj, screenWidth-1250, + screenHeight-50, 0, -10, squish.Qt.NoModifier) + else: + squish.mouseWheel(ScreenObj, screenWidth-1000, + screenHeight-10, 0, -50, squish.Qt.NoModifier) raise LookupError("zone object is not in view to the user after " + \ "trying 100 times") Index: shared/scripts/names.py =================================================================== diff -u -r27243911dd859b5a1b97d69637e108763f955cd4 -r568e97ea04d6b8bd977bf3533980a42b26ec951e --- shared/scripts/names.py (.../names.py) (revision 27243911dd859b5a1b97d69637e108763f955cd4) +++ shared/scripts/names.py (.../names.py) (revision 568e97ea04d6b8bd977bf3533980a42b26ec951e) @@ -67,8 +67,21 @@ #alarm list notification_bar_alarm_list_button = {"container": o_Gui_MainView, "id": "_alarmListImage", "source": "qrc:/images/iList", "type": "Image", "unnamed": 1, "visible": True} -alarm_notification_maximize_button = {"container": o_Gui_MainView, "gradient": 0, "id": "_updownButton", "type": "UpDownButton", "unnamed": 1, "visible": True} +maximize_button = {"container": o_Gui_MainView, "gradient": 0, "id": "_updownButton", "type": "UpDownButton", "unnamed": 1, "visible": True} alarm_list_title_text = {"container": o_Overlay, "text": "Alarm list", "type": "Text", "unnamed": 1, "visible": True} dialogue_bar_alarm_list_button = {"container": o_Overlay, "id": "_icon", "source": "qrc:/images/iList", "type": "Image", "unnamed": 1, "visible": True} +alarm_list_minimize_maximize_button = {"container": o_Overlay, "id": "_image", "source": "qrc:/images/iList", "type": "Image", "unnamed": 1, "visible": True} +alarm_id = {"container": o_Overlay, "id": "_text", "type": "Text", "unnamed": 1, "visible": True} +alarm_message = {"container": o_Overlay, "id": "_itemsValue", "type": "Text", "unnamed": 1, "visible": True} +alarm_list = {"container": o_Overlay, "id": "_grid", "type": "Grid", "unnamed": 1, "visible": True} +rejected_alarm_list_msg = {"container": o_Overlay, "id": "_desc", "objectName": "_NotificationDialog_Description", "type": "Text", "visible": True} +def get_alarm_id_obj(id): + alarm_id["text"] = id + return alarm_id + +def get_alarm_msg_obj(msg): + alarm_message["text"] = msg + return alarm_message + \ No newline at end of file Fisheye: Tag 568e97ea04d6b8bd977bf3533980a42b26ec951e refers to a dead (removed) revision in file `tst_ui_alarms/test.py'. Fisheye: No comparison available. Pass `N' to diff? Index: tst_ui_alarms_list/test.py =================================================================== diff -u -r27243911dd859b5a1b97d69637e108763f955cd4 -r568e97ea04d6b8bd977bf3533980a42b26ec951e --- tst_ui_alarms_list/test.py (.../test.py) (revision 27243911dd859b5a1b97d69637e108763f955cd4) +++ tst_ui_alarms_list/test.py (.../test.py) (revision 568e97ea04d6b8bd977bf3533980a42b26ec951e) @@ -18,60 +18,244 @@ # from dialin.ui import unittests from builtins import int as pyInt -from configuration.assertion_helper import * from configuration.config import * -from configuration.utility import start_application +from configuration.utility import start_application, scroll_to_zone from dialin.ui.hd_simulator import HDSimulator # from dialin.ui.dg_simulator import DGSimulator from dialin.protocols.CAN import DenaliCanMessenger from dialin.ui.hd_simulator_alarms import HDAlarmsSimulator +from random import randint, choice, choices +from names import rejected_alarm_list_msg - -assertion = AssertionHelper() + hd = HDSimulator() logging.basicConfig(filename='log_file.log',level=logging.INFO,\ - format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S') logger = logging.getLogger("INFO") messenger = DenaliCanMessenger('can0') alarm = HDAlarmsSimulator(can_interface=messenger, logger=logger) +NUM_OF_MSG_ID = 289 -def maximize(): + +def maximize()-> None: """ Method to maximize the notification bar """ mouseClick(waitForObject(names.alarm_notification_maximize_button)) -def minimize(): +def minimize()-> None: """ Method to minimize the Alarm Dialogue bar """ mouseClick(waitForObject(names.o_minimizeButton_UpDownButton)) def set_only_alarm_list_btn(): + """ + Method to remove the minimize + and maximize button + @return : flags + """ flags = alarm.cmd_make_alarm_flags(no_minimize=1) - alarm.cmd_activate_alarm_id(state = ALARM_PRIORITY_NONE, - alarm = 1, - escalates_in = 0, - silence_expires = 0, - flags = flags) + return flags + + +def open_alarm_list_when_only_alarm_list_btn_is_available(): + """ + Method to open 'Alarm list' when + only 'Alarm list' button is available + """ + test.log("Opening 'Alarm list'") + tapObject(waitForObjectExists(names.alarm_list_minimize_maximize_button)) + alarm_list_text = waitForObject(names.alarm_list_title_text) + if alarm_list_text.visible is False: + tapObject(waitForObject(names.alarm_list_minimize_maximize_button)) + else: + test.log("Alarm List is displayed") + alarm_list_title_text = alarm_list_text.text.toUtf8().constData() + test.compare(alarm_list_title_text, ALARM_LIST_TITLE) + + +def generate_alarm_ids(): + """ + Method to generate 10 random + alarm IDs + @return alarm_id_list: list of 10 random alarm IDs + """ + alarm_id_list = [] + id_count = 0 + while id_count < 10: + id = randint(1, NUM_OF_MSG_ID) + if id in alarm_id_list: + pass + else: + alarm_id_list.append(id) + id_count += 1 + return alarm_id_list + + +def generate_states(): + """ + Method to generate 10 states + between HIGH, MEDIUM, LOW, NONE + @return id_list: list of 10 states + """ + state_list = [] + state_count = 0 + state_list = choices(list(ALARM_PRIORITIES), k=10) + return state_list + + +def set_the_alarm(alarm_id_list, state_list, flags=None): + """ + Method to set the alarm + @param alarm_id_list: List of Alarm IDs + @param state_list: List of Alarm States(HIGH/MEDIUM/LOW) + @flags: (int) See 'cmd_make_alarm_flags' + """ + test.startSection("Settings Alarms") + for index, alarm_id in enumerate(alarm_id_list): + test.log(f"Setting alarm priority '{ALARM_PRIORITIES[state_list[index]]}'" + + f" for Alarm ID '{alarm_id}' and its respective message " + + f"'{ALARM_ID_AND_MESSAGES[alarm_id]}'") + + alarm.cmd_activate_alarm_id(state=state_list[index], + alarm=alarm_id, + flags=flags) + test.endSection() - +def arrange_the_alarm_list(alarm_id_list, accept=ACCEPTED, reason_id=0): + """ + Method to arrange the alarm list + and Accept or Reject the Alarm list + @param alarm_id_list: list of activated Alarm IDs + @param accept: Bool if the list is Accepted/Rejected + @param reason: (int) Reason of Rejection + """ + arranged_alarm_list = [] + count = len(alarm_id_list) + for i in range(count): + alarm_id = choice(alarm_id_list) + arranged_alarm_list.append(alarm_id) + alarm_id_list.remove(alarm_id) + alarm.cmd_send_active_list_response(accept=accept, + reason=reason_id, + a0=arranged_alarm_list[0], a1=arranged_alarm_list[1], + a2=arranged_alarm_list[2], a3=arranged_alarm_list[3], + a4=arranged_alarm_list[4], a5=arranged_alarm_list[5], + a6=arranged_alarm_list[6], a7=arranged_alarm_list[7], + a8=arranged_alarm_list[8], a9=arranged_alarm_list[9]) + return arranged_alarm_list + +def verify_alarm_list(arranged_alarm_list, accept=None, reason_id=0): + """ + Method to verify the Messages under + 'Alarm list' + @param arranged_alarm_list: list alarm list + @param accept: bool Accepted/Rejected + @param reason_id: Reason for rejecting the alarm list + """ + test.startSection("Verify the Messages under 'Alarm list'") + if accept==ACCEPTED: + alarm_list_index = {} + alarm_id_parent_list = {} + for index, id in enumerate(arranged_alarm_list): + + scroll_to_zone(zone=names.get_alarm_id_obj(id=id), + screen_object=names.o_Overlay, screen="pop up") + alarm_id = waitForObject(names.get_alarm_id_obj(id=id)) + alarm_id_parent = object.parent(alarm_id) + alarm_id_parent_list[id] = alarm_id_parent + alarm_msg = waitForObject(\ + names.get_alarm_msg_obj(msg=ALARM_ID_AND_MESSAGES[id])) + test.log("Verifying 'Alarm ID'") + alarm_id = pyInt(alarm_id.text.toUtf8().constData()) + test.compare(alarm_id, id, f"Actual 'Alarm ID': {alarm_id} " + + f"should be equal to Expected 'Alarm ID': {id}") + + test.log("Verifying 'Alarm Message'") + alarm_msg = alarm_msg.text.toUtf8().constData() + test.compare(alarm_msg, ALARM_ID_AND_MESSAGES[id], + f"Actual 'Alarm Message': {alarm_msg} " + + "should be equal to Expected " + + f"'Alarm Message': {ALARM_ID_AND_MESSAGES[id]}") + alarm_list_index[id] = index + + test.log("Verifying the Alarm's position in 'Alarm list'") + alarm_list_parent = waitForObject(names.alarm_list) + alarm_list = object.children(alarm_list_parent) + + for index, alarm_id in enumerate(alarm_id_parent_list): + test.compare(alarm_list[index], + alarm_id_parent_list[alarm_id], + f"Alarm ID: {alarm_id} is at position {index}" ) + elif accept==REJECTED: + + expected_message = f"{REJECTION_REASON[0]}\n{REJECTION_REASON[reason_id]}" + rejected_alarm_list_msg = waitForObject(names.rejected_alarm_list_msg) + rejected_alarm_list_msg = rejected_alarm_list_msg.text.toUtf8().constData() + test.compare(rejected_alarm_list_msg, expected_message, + "When 'Alarm list' is not accepted " + + f"then '{expected_message}' should be displayed " + + "on 'Alarm List' pop up") + test.endSection() + + +def verify_alarm_list_when_only_alarm_list_button_is_available(accept=None, reason_id=None): + """ + Method to set the alarms, arrange them + in a list and verify the correct alarm ID + and its respective message is added to the list + """ + alarm_id_list = generate_alarm_ids() + set_the_alarm(alarm_id_list=alarm_id_list, + state_list=generate_states(), + flags=set_only_alarm_list_btn()) + arranged_alarm_list = arrange_the_alarm_list(alarm_id_list=alarm_id_list, + accept=accept,reason_id=reason_id ) + snooze(2) + open_alarm_list_when_only_alarm_list_btn_is_available() + snooze(5) + verify_alarm_list(arranged_alarm_list=arranged_alarm_list, + accept=accept,reason_id=reason_id ) + + + def main(): utils.tstStart(__file__) startApplication(AUT_NAME) - set_only_alarm_list_btn() - snooze(10) + test.log("GIVEN: 10 Alarms are generated") + test.log("AND: Minimize button is removed") + test.log("WHEN: Arranged 10 Alarms under 'Alarm list'") + test.log("AND: 'Alarm list is accepted and 'Alarm list'" + + "is opened") + test.log("THEN: All the 10 Alarms is displayed in 'Alarm list' " + + "in defined order") + verify_alarm_list_when_only_alarm_list_button_is_available(accept=ACCEPTED, + reason_id=0) + test.log("GIVEN: 10 Alarms are generated") + test.log("AND: Minimize button is removed") + test.log("WHEN: Arranged 10 Alarms under 'Alarm list'") + test.log("AND: 'Alarm list is Rejected and 'Alarm list'" + + "is opened") + test.log("THEN: Only rejection message should display and " + + "No Alarms should be displayed") + verify_alarm_list_when_only_alarm_list_button_is_available(accept=REJECTED, + reason_id=7) + + + + +