# -*- 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 import utils from configuration import config, utility from builtins import int as pyInt from builtins import str as pyStr hd_simulator = HDSimulator() PRE_TREATMENT_PATIENT_CONNECTION_MODE = 8 UF_PRE_TREATMENT_STEPS = 5 BP_HR_PRE_TREATMENT_STEPS = 6 CONNECTION_PRE_TREATMENT_STEPS = 7 TREATMENT_ULTRAFILTERATION_TESTING_OPTION = { "OPTION_1" : {"uf_maximum" : 800, "uf_minimum" : 0}, "OPTION_2" : {"uf_maximum" : 500, "uf_minimum" : 0}, "OPTION_3" : {"uf_maximum" : 550, "uf_minimum" : 0}, "OPTION_4" : {"uf_maximum" : 300, "uf_minimum" : 0}, "OPTION_5" : {"uf_maximum" : 280, "uf_minimum" : 0}, "OPTION_6" : {"uf_maximum" : 765, "uf_minimum" : 0}, "OPTION_7" : {"uf_maximum" : 680, "uf_minimum" : 0}, "OPTION_8" : {"uf_maximum" : 1500, "uf_minimum" : 0}, "OPTION_9" : {"uf_maximum" : 390, "uf_minimum" : 0}, "OPTION_10" : {"uf_maximum" : 800, "uf_minimum" : 0}, "OPTION_11" : {"uf_maximum" : 1000, "uf_minimum" : 0}, "OPTION_12" : {"uf_maximum" : 1250, "uf_minimum" : 0}, } def test_rejection_message_patient_connection(accept_status): """ verification of rejection messages during patient connection. @param accept_status: (int) boolean accept/reject response @return: none """ test.startSection("verification 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) 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 keypad_input(key_value): """ Method to enter values using application UI keyboard @param key_value: (str) User expected value """ if key_value is not None: names.o_keypad_input["text"] = key_value return names.o_keypad_input else: test.log("Invalid text for object.") names.o_keypad_input["text"] = None def enter_keypad_value(entry): """ Method to enter user desired value using keypad @param entry: (str) User expected value """ test.startSection("Entering {}".format(entry)) entry = pyStr(entry) #type casted into string format for value in entry: mouseClick(waitForObject(keypad_input(value))) test.endSection() def erase_entered_value(input_field): """ Method to erase the entered value @param input_field - (obj) object of input field """ input_field = waitForObject(input_field).text for value in input_field: mouseClick(squish.waitForObjectExists(names.o_back_space_key)) test.log("user cleared pre-used value") 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)) erase_entered_value(names.o_PreTreatmentBase_input_TextInput_2) 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)) 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)) erase_entered_value(names.o_PreTreatmentBase_input_TextInput_3) 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)) 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)) erase_entered_value(names.o_PreTreatmentBase_input_TextInput_4) 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)) 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_color_of_entry(entry = 0, vital_parameter = None, input_field = None): """ Method to verify the color of entry of systolic, diastolic and heart rate @param entry: (int) user entered value @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) @param input_field - (obj) object of input field """ test.startSection("Verify the color of {} value {}".format(vital_parameter, entry)) input_field_color = input_field.color.name entry = pyInt(entry) if vital_parameter is config.SYSTOLIC_TEXT: if (entry < config.SYSTOLIC_LOWER_LIMIT) or (entry > config.SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) elif (entry >= config.SYSTOLIC_LOWER_LIMIT) and (entry <= config.SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, config.IN_RANGE_COLOR, "systolic value {} is in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) elif vital_parameter is config.DIASTOLIC_TEXT: if (entry < config.DIASTOLIC_LOWER_LIMIT) or (entry > config.DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) elif (entry >= config.DIASTOLIC_LOWER_LIMIT) and (entry <= config.DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color, config.IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) elif vital_parameter is config.HEART_RATE_TITLE: if (entry < config.HEART_RATE_LOWER_LIMIT) or (entry > config.HEART_RATE_UPPER_LIMIT): test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) elif (entry >= config.HEART_RATE_LOWER_LIMIT) and (entry <= config.HEART_RATE_UPPER_LIMIT): test.compare(input_field_color,config.IN_RANGE_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) test.endSection() def test_patient_connection_instruction_screen(screen_indicator): """ verification of patient connection instruction screen @param slider_value: (int) value of the slider to set. @return N/A """ test.startSection("verification of instruction screen -> " + str(screen_indicator+1)) #Forward navigation of tutorial pages for instruction_screen in range(screen_indicator): mouseClick(waitForObject(names.o_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.") #FIXME : Tutorial texts have bug. avoiding verification till fix utility.training_screen_indicator_verification(screen_indicator, names.o_PreTreatmentBase_Indicators) if screen_indicator == 3: 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_PreTreatmentBase_leftImage_Image)) test.endSection() def drag_and_drop_ultrafilteration_slider(slider_value = 0, maximum_ultrafilteration = 0): """ Tests to verify ultrafilteration slider range @param slider_value: (int) value of the slider to set. """ slider_buffer = (config.UF_MAXIMUM_SLIDER_WIDTH/(maximum_ultrafilteration/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) def start_test_treatment_ultrafilteration(ultrafilteration_range): """ Test slider movement of ultrafilteration volume. @param ultrafilteration_range: (dictionary) uf minimum and uf maximum volume. @return: N/A """ test.startSection("verification of ultrafilteration slider hacing" +str(ultrafilteration_range)+ " adjustment") min_uf = ultrafilteration_range["uf_minimum"] max_uf = ultrafilteration_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_ultrafilteration_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)) #FIXME: minimum value of the slider is unchanged based on simulator input 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 test_vital_entries_on_patient_connection(): """ Method to verify BP/HR section from patient connection. @param : N/A @return: N/A """ test.startSection("verification of 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(2) #navigate to pre treatment hd_simulator.cmd_set_hd_operation_mode_data(5,0) #navigate to patient connection sub mode navigate_patient_connection(PRE_TREATMENT_PATIENT_CONNECTION_MODE) #verification of indicators from patient connection section utility.page_step_indicator_verification(UF_PRE_TREATMENT_STEPS, names.o_PreTreatmentUltrafiltration_Indicators) #verification of uf slider based on edge condition. start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_1"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_2"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_3"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_4"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_5"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_6"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_7"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_8"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_9"]) start_test_treatment_ultrafilteration(TREATMENT_ULTRAFILTERATION_TESTING_OPTION["OPTION_10"]) #verification of rejection message test_rejection_message_patient_connection(accept_status = False) #cmd to navigate to BP/HR section hd_simulator.cmd_send_uf_treatment_response(accepted = True, reason = 0, volume = config.UF_VALID_RANGE) #verification of indicators from BP/HR section utility.page_step_indicator_verification(BP_HR_PRE_TREATMENT_STEPS, names.o_PreTreatmentFlowBase_Indicators) #verification of BP/HR entries based on edge condition test_vital_entries_on_patient_connection() #verification of indicators from Connection section utility.page_step_indicator_verification(CONNECTION_PRE_TREATMENT_STEPS, names.o_PreTreatmentBase_nextStepsBullet_StepBullet) #verification of tutorial section test_patient_connection_instruction_screen(screen_indicator = 0) test_patient_connection_instruction_screen(screen_indicator = 1) test_patient_connection_instruction_screen(screen_indicator = 2) test_patient_connection_instruction_screen(screen_indicator = 3) utils.tstDone()