# -*- 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_pre_treatment_patient_connection # date 2020/03/12 # author Joseph Varghese # # NOTE: # This test contradicts verification of patient connection screens. # import names from dialin.ui.hd_simulator import HDSimulator from dialin.ui.hd_simulator_alarms import HDAlarmsSimulator from dialin.ui import utils from configuration import config, utility from builtins import str as pyStr from dialin.common.hd_defs import HDOpModes, PreTreatmentSubModes from dialin.ui.utils import waitForGUI from dialin.protocols.CAN import DenaliCanMessenger import logging hd_simulator = HDSimulator() logger = logging.getLogger("INFO") messenger = DenaliCanMessenger('can0') alarm = HDAlarmsSimulator(can_interface=messenger, logger=logger) PRE_TREATMENT_PATIENT_CONNECTION_MODE = PreTreatmentSubModes.HD_PRE_TREATMENT_PATIENT_CONNECTION_STATE.value UF_PRE_TREATMENT_STEPS = 5 BP_HR_PRE_TREATMENT_STEPS = 6 CONNECTION_PRE_TREATMENT_STEPS = 7 def verify_instruction_screen_indicator(current_indicator, training_items_object): """ Method to verify the pre treatment tutorial indicators on top of the screen which indicates the steps passed, current, remained] @param current_indicator :(int) Current pre-treatment tutorial indicator @param training_items_object :(dictionary) pre_treatment bullet object """ test.startSection("Verify the Page Step indicators from training screen") for page in range(config.TRAINING_INDICATOR_SCREEN): occurrence_index = 10 + page #1-9 occurrence of object belongs to page indicators, 10 - 13 occurrence of object belongs to training indicators training_items_object["occurrence"] = occurrence_index bullet_children = object.children(waitForObject(training_items_object)) bullet_circle_color = bullet_children[0].color.name bullet_border_color = bullet_children[0].border.color.name #To verify the step indicators of pre treatment tutorial screens if page < current_indicator: test.verify(waitForObjectExists(training_items_object).complete, "bullet indicator {index} should be in complete state".format(index=current_indicator)) test.verify(not waitForObjectExists(training_items_object).current, "bullet indicator {index} current attribute should be unchecked".format(index=current_indicator)) test.compare(bullet_circle_color, config.COMPLETE_COLOR, " bullet color hex should be "+str(config.COMPLETE_COLOR)) test.compare(bullet_border_color, config.COMPLETE_COLOR, " bullet border color hex should be "+str(config.COMPLETE_COLOR)) #To verify the step indicators of pre treatment tutorial screen elif page == current_indicator: test.verify(waitForObjectExists(training_items_object).current, "bullet indicator {index} should be in complete state".format(index=current_indicator)) test.verify(not waitForObjectExists(training_items_object).complete, "bullet indicator {index} current attribute should be unchecked".format(index=current_indicator)) test.compare(bullet_circle_color,config.COMPLETE_COLOR, "bullet color hex should be "+str(config.CURRENT_COLOR)) test.compare(bullet_border_color,config.COMPLETE_COLOR, "bullet border color hex should be "+str(config.COMPLETE_COLOR)) #To verify the step indicators of pre-treatment tutorial screens else: test.verify(not waitForObjectExists(training_items_object).current, "bullet indicator {index} should not be complete state".format(index=current_indicator)) test.verify(not waitForObjectExists(training_items_object).complete, "bullet indicator {index} current attribute should be unchecked".format(index=current_indicator)) test.compare(bullet_circle_color,config.CURRENT_COLOR, "bullet circle color hex should be "+str(config.CURRENT_COLOR)) test.compare(bullet_border_color,config.INCOMPLETE_COLOR, "bullet border color hex should be "+str(config.INCOMPLETE_COLOR)) test.endSection() def verify_rejection_message_patient_connection(accept_status): """ Method to verify rejection messages during patient connection. @param accept_status: (int) boolean accept/reject response """ test.startSection("verifying of rejection messages on patient connection") for rejection in range(1, config.NUM_OF_REQUEST_REJECT_REASONS): hd_simulator.cmd_send_uf_treatment_response(accepted=accept_status, reason=rejection, volume=config.UF_VALID_RANGE) alarm.cmd_activate_alarm_id(0, 0, 0, 0, 0) #send alarm 0 when fixed this line can be removed rejection_message = waitForObject(names.o_PreTreatmentUltrafiltration_NotificationBar_NotificationBar) test.compare(rejection_message.text, config.REJECTION_REASON[rejection], "expected rejection {msg} displayed".format(msg=config.REJECTION_REASON[rejection])) test.endSection() def verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val, dia_val, heart_rate): """ Method to enter systolic, diastolic and heart rate value and save or unsave it and verify same is updated in pre-treatment screen. @param sys_val - (int) user expected systolic pressure @param dia_val - (int) user expected diastolic pressure @param heart_rate - (int) user expected heart rate @param save - (bool) True/False """ test.startSection("Verify the entered systolic, diastolic and heart rate value updated in main-treatement screen") mouseClick(waitForObject(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry)) utility.erase_entered_value(names.o_PreTreatmentBase_input_TextInput_2) utility.enter_keypad_value(sys_val) test.verify(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry).enabled, "systolic combo box should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry).text, str(sys_val), "systolic value should be : " + str(sys_val)) utility.verify_color_of_entry(entry=sys_val, vital_parameter=config.SYSTOLIC_TEXT, input_field=waitForObject(names.o_PreTreatmentBase_input_TextInput_2)) mouseClick(waitForObject(names.o_PreTreatmentBase_input_TextInput_3)) utility.erase_entered_value(names.o_PreTreatmentBase_input_TextInput_3) utility.enter_keypad_value(dia_val) test.verify(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureDiastolic_TextEntry).enabled, "diastolic value should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureDiastolic_TextEntry).text, str(dia_val), "diastolic value should be : " + str(dia_val)) utility.verify_color_of_entry(entry=dia_val, vital_parameter=config.DIASTOLIC_TEXT, input_field=waitForObject(names.o_PreTreatmentBase_input_TextInput_3)) mouseClick(waitForObject(names.o_PreTreatmentBase_input_TextInput_4)) utility.erase_entered_value(names.o_PreTreatmentBase_input_TextInput_4) utility.enter_keypad_value(heart_rate) test.verify(waitForObjectExists(names.o_PreTreatmentBase_heartRate_TextEntry).enabled, "diastolic value should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_heartRate_TextEntry).text, str(heart_rate), "diastolic value should be : "+str(dia_val)) utility.verify_color_of_entry(entry=heart_rate, vital_parameter=config.HEART_RATE_TITLE, input_field=waitForObject(names.o_PreTreatmentBase_input_TextInput_4)) test.endSection() def verify_patient_connection_instruction_screen(): """ Method to verify patient connection instruction screen @param slider_value: (int) value of the slider to set. """ test.startSection("Verifying of instruction screen ") #Method to get number of instruction screens for patient connection during run time. childObjects = object.children(waitForObject(names.o_PreTreatmentBase_gridSteps_Grid)) #Initializing instruction_screen as 0, and type casting instruction_screen as integer. instruction_screen = 0 for child in childObjects: if str(child.id) != "_tailStepsRepeater": instruction_screen = instruction_screen + 1 for screen_indicator in range(instruction_screen): #Forward navigation of tutorial pages for instruction_screen in range(screen_indicator): mouseClick(waitForObject(names.o_patient_connection_PreTreatmentBase_rightImage_Image)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_Patient_Connection_Text).text, config.PATIENT_CONNECTION_TEXT, "Patient connection text should be {msg}".format(msg=config.PATIENT_CONNECTION_TEXT)) test.compare(waitForObjectExists(names.o_swipeview_tutorial_text).enabled, True, "Tutorial text should be enabled.") verify_instruction_screen_indicator(screen_indicator, names.o_PreTreatmentBase_Indicators) if screen_indicator == 4: test.verify(waitForObjectExists(names.o_PreTreatmentBase_Continue_Text).enabled, "continue button should be disabled") else: test.verify(not waitForObjectExists(names.o_PreTreatmentBase_Continue_Text).enabled, "continue button should be disabled") #Reverse navigation of tutorial pages for instruction_screen in range(screen_indicator): mouseClick(waitForObject(names.o_patient_connection_PreTreatmentBase_leftImage_Image)) for instruction_screen in range(4): mouseClick(waitForObject(names.o_patient_connection_PreTreatmentBase_rightImage_Image)) mouseClick(waitForObjectExists(names.o_pretreatment_instruction_continue_btn)) hd_simulator.cmd_send_pre_treatment_patient_connection_confirm_response(accepted=True, reason=0) utils.waitForGUI(1) mouseClick(waitForObjectExists(names.o_patient_connection_start_btn)) test.endSection() def drag_and_drop_ultrafiltration_slider(slider_value=0, maximum_ultrafiltration=0): """ Method to verify ultrafiltration slider range @param slider_value: (int) value of the slider to set. """ slider_buffer = (config.UF_MAXIMUM_SLIDER_WIDTH/(maximum_ultrafiltration/100)) * slider_value slider_width = slider_buffer + config.UF_MINIMUM_SLIDER_WIDTH mouseClick(waitForObject(names.o_PreTreatmentUltrafiltration_volumeSlider_Slider), slider_width , 3, Qt.LeftButton) utils.waitForGUI(0.1) test.compare(waitForObject(names.o_PreTreatmentUltrafiltration_volumeSlider_Slider).value , (slider_value/10), "user adjusted slider value to -> "+ str(slider_value)) def navigate_patient_connection(pre_treatment_sub_mode): """ Method to navigate to sub mode under pre-treatment screen @param mode - (int) pre treatment state """ hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=pre_treatment_sub_mode, water_sample_state=0, consumables_self_test_state=0,no_cartridge_self_test_state=0, installation_state=0, dry_self_test_state=0, prime_state=0, recirculate_state=0, patient_connection_state=0,wet_selftests_state=0, pretreatment_rsrvr_state=0) def start_test_treatment_ultrafiltration(ultrafiltration_range): """ Verify slider movement of ultrafiltration volume. @param ultrafiltration_range: (dictionary) uf minimum and uf maximum volume. """ test.startSection("Verifiying of ultrafiltration slider hacing" + str(ultrafiltration_range) + " adjustment") min_uf = ultrafiltration_range["uf_minimum"] max_uf = ultrafiltration_range["uf_maximum"] hd_simulator.cmd_set_treatment_parameter_ranges(0, 100, 0, max_uf, 0, 0) for uf_value in range(1, (max_uf//100)+1, 1): drag_and_drop_ultrafiltration_slider(uf_value, max_uf) test.compare(utils.l2ml(waitForObjectExists(names.o_PreTreatmentUltrafiltration_volumeSlider_Slider).maximum), max_uf, "maximum uf value should be :" + str(max_uf)) test.compare(utils.l2ml(waitForObjectExists(names.o_PreTreatmentUltrafiltration_volumeSlider_Slider).minimum), min_uf, "minimum uf value should be :" + str(min_uf)) test.compare(waitForObjectExists(names.o_PreTreatmentUltrafiltration_Ultrafiltration_Volume_Text).text, config.UF_VOLUME_TEXT, "uf volume text should be " + config.UF_VOLUME_TEXT) test.compare(waitForObjectExists(names.o_PreTreatmentUltrafiltration_Ultrafiltration_Setup_Text).text, config.UF_TITLE_TEXT, "uf title text should be "+config.UF_TITLE_TEXT) test.endSection() def verify_vital_entries_on_patient_connection(): """ Method to verify BP/HR section from patient connection. """ test.startSection("Verifying BP/HR section from patient connection") test.compare(waitForObjectExists(names.o_PreTreatmentBase_BP_HR_Text).text, config.BP_HR_TEXT, "BP/HR title text should be :" + str(config.BP_HR_TEXT)) test.compare(waitForObjectExists(names.o_PreTreatmentbase_skip_text).text, config.SKIP_TEXT, "BP/HR button text should be " + str(config.SKIP_TEXT)) test.verify(waitForObjectExists(names.o_PreTreatmentbase_skip_text).enabled, "BP/HR button should enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_Blood_Pressure_Text).text, config.BLOOD_PRESSURE_TITLE, "BP title text should be :" + str(config.BLOOD_PRESSURE_TITLE)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_mmHg_Label).text, config.BLOOD_PRESSURE_UNIT, "BP unit should be " + str(config.BLOOD_PRESSURE_UNIT)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_Heart_Rate_Text).text, config.HEART_RATE_TITLE, "HR text should be :" + str(config.HEART_RATE_TITLE)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_BPM_Label).text, config.HEART_RATE_UNIT, "BP unit should be " + str(config.HEART_RATE_UNIT)) verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_120, dia_val=config.DIASTOLIC_PRESSSURE_80, heart_rate=config.HEART_RATE_VAL_101) test.verify(waitForObjectExists(names.o_PreTreatmentBase_CONFIRM_Text_2).enabled, "Confirm button is enabled.") verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_113, dia_val=config.DIASTOLIC_PRESSSURE_60, heart_rate=config.HEART_RATE_VAL_60) test.verify(waitForObjectExists(names.o_PreTreatmentBase_CONFIRM_Text_2).enabled, "Confirm button is enabled.") verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_15, dia_val=config.DIASTOLIC_PRESSSURE_85, heart_rate=config.HEART_RATE_VAL_100) test.verify(waitForObjectExists(names.o_PreTreatmentbase_skip_text).enabled, "skip button is enabled.") verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_150, dia_val=config.DIASTOLIC_PRESSSURE_25, heart_rate=config.HEART_RATE_VAL_110) test.verify(waitForObjectExists(names.o_PreTreatmentbase_skip_text).enabled, "skip button is enabled.") verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_200, dia_val=config.DIASTOLIC_PRESSSURE_200, heart_rate=config.HEART_RATE_VAL_200) test.verify(waitForObjectExists(names.o_PreTreatmentbase_skip_text).enabled, "skip button is enabled.") verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_175, dia_val=config.DIASTOLIC_PRESSSURE_74, heart_rate=config.HEART_RATE_VAL_85) test.verify(waitForObjectExists(names.o_PreTreatmentBase_CONFIRM_Text_2).enabled, "Confirm button is enabled.") verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_59, dia_val=config.DIASTOLIC_PRESSSURE_39, heart_rate=config.HEART_RATE_VAL_39) test.verify(waitForObjectExists(names.o_PreTreatmentbase_skip_text).enabled, "skip button is enabled.") verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_251, dia_val=config.DIASTOLIC_PRESSSURE_201, heart_rate=config.HEART_RATE_VAL_181) test.verify(waitForObjectExists(names.o_PreTreatmentbase_skip_text).enabled, "skip button is enabled.") mouseClick(waitForObject(names.o_PreTreatmentbase_skip_text)) test.compare(waitForObjectExists(names.o_swipeview_tutorial_text).enabled, True, "Tutorial text should be enabled.") mouseClick(waitForObject(names.o_PreTreatmentBase_BACK_Text)) verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_200, dia_val=config.DIASTOLIC_PRESSSURE_150, heart_rate=config.HEART_RATE_VAL_70) mouseClick(waitForObject(names.o_PreTreatmentBase_CONFIRM_Text_2)) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) utils.waitForGUI(1) #navigate to pre treatment hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_PRET.value, 0) #navigate to patient connection sub mode navigate_patient_connection(PRE_TREATMENT_PATIENT_CONNECTION_MODE) #verification of indicators from patient connection section utility.verify_page_step_indicator(names.o_PreTreatmentStack_pretreatmentConnectionStack_PreTreatmentConnectionStack, UF_PRE_TREATMENT_STEPS, config.PRE_TREATMENT_SCREENS) #verification of uf slider based on edge condition. for ranges in config.ULTRAFILTRATION_VOLUME_COMBINATION_FROM_ULTRAFILTRATION_SETUP_SCREEN: start_test_treatment_ultrafiltration(config.ULTRAFILTRATION_VOLUME_COMBINATION_FROM_ULTRAFILTRATION_SETUP_SCREEN[ranges]) #verification of rejection message verify_rejection_message_patient_connection(accept_status=False) mouseClick(waitForObjectExists(names.o_pretreatment_ultrafilteration_confirm_btn)) hd_simulator.cmd_send_pre_treatment_continue_to_treament_response(accepted=False, reason=1) hd_simulator.cmd_send_pre_treatment_continue_to_treament_response(accepted=True, reason=0) hd_simulator.cmd_send_pre_treatment_patient_connection_confirm_response(accepted=False, reason=0) hd_simulator.cmd_send_pre_treatment_patient_connection_confirm_response(accepted=True, reason=0) #cmd to navigate to BP/HR section hd_simulator.cmd_send_uf_treatment_response(accepted=False, reason=1, volume=config.UF_VALID_RANGE) hd_simulator.cmd_send_uf_treatment_response(accepted=True, reason=0, volume=config.UF_VALID_RANGE) #verification of indicators from BP/HR section utility.verify_page_step_indicator(names.o_PreTreatmentStack_pretreatmentConnectionStack_PreTreatmentConnectionStack, BP_HR_PRE_TREATMENT_STEPS, config.PRE_TREATMENT_SCREENS) #verification of BP/HR entries based on edge condition verify_vital_entries_on_patient_connection() #verification of indicators from Connection section utility.verify_page_step_indicator(names.o_PreTreatmentStack_pretreatmentConnectionStack_PreTreatmentConnectionStack, CONNECTION_PRE_TREATMENT_STEPS, config.PRE_TREATMENT_SCREENS) #verification of tutorial section verify_patient_connection_instruction_screen() utils.tstDone()