# -*- 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.common.hd_defs import PreTreatmentSubModes from dialin.common.msg_defs import RequestRejectReasons from dialin.common.hd_defs import HDOpModes from dialin.ui import utils from configuration import config, utility hd_simulator = HDSimulator() SYSTOLIC_PRESSSURE_120 = "120" SYSTOLIC_PRESSSURE_113 = "113" SYSTOLIC_PRESSSURE_200 = "200" SYSTOLIC_PRESSSURE_175 = "175" DIASTOLIC_PRESSSURE_74 = "74" DIASTOLIC_PRESSSURE_150 = "150" DIASTOLIC_PRESSSURE_80 = "80" DIASTOLIC_PRESSSURE_60 = "60" HEART_RATE_VAL_101 = "101" HEART_RATE_VAL_60 = "60" HEART_RATE_VAL_70 = "70" HEART_RATE_VAL_85 = "85" DIASTOLIC_TEXT = "diastolic" SYSTOLIC_TEXT = "systolic" BLOOD_PRESSURE_DEFAULT_VAL = "__ / __" HEART_RATE_DEFAULT_VAL = "__" INVALID_VALS = {"systolic" : [260, 59, 300, 23], "diastolic": [39, 1, 210, 201], "Heart Rate": [181, 200, 39, 20]} PRE_TREATMENT_PATIENT_CONNECTION_MODE = 8 UF_PRE_TREATMENT_STEPS = 5 BP_HR_PRE_TREATMENT_STEPS = 6 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} } 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 saline bolus") 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 applicatio 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"] = "Q" def enter_keypad_value(entry): """ Method to enter user desired value using keypad @param entry: (str) User expected value """ test.startSection("Entering {}".format(entry)) for value in entry: # value = int(value) 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: test.log(str(value)) mouseClick(squish.waitForObjectExists(names.o_back_space_key)) test.compare(input_field, "", "Input field should be empty") def verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val, dia_val, heart_rate, save): """ 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(str(sys_val)) test.verify(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry).enabled, "systolic value 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=SYSTOLIC_TEXT, input_field=waitForObject(names.o_PreTreatmentBase_input_TextInput_2)) mouseClick(waitForObject(names.o_pop_up_diastolic_input_field)) erase_entered_value(diastolic) enter_keypad_value(str(dia_val)) verify_entered_value_in_pop_up(value=str(dia_val), input_field=diastolic, vital=DIASTOLIC_TEXT) verify_color_of_entry(entry=dia_val, vital_parameter=DIASTOLIC_TEXT, input_field=diastolic) hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) erase_entered_value(hr) enter_keypad_value(str(heart_rate)) verify_entered_value_in_pop_up(value=str(heart_rate), input_field=hr, vital=HEART_RATE_TITLE) verify_color_of_entry(entry=heart_rate, vital_parameter=HEART_RATE_TITLE, input_field=hr) if save: test.log("Clicking confirm button") confirm_button = waitForObjectExists(names.o_vitals_confrim_btn) test.compare(confirm_button.enabled, True, "Valid Blood Pressure and Heart is entered therefore confirm button is enabled") saved_time = get_current_date_and_time() mouseClick(confirm_button) verify_last_read_time(saved_time) elif save is False: mouseClick(waitForObject(names.o_vitals_close_btn)) test.log("'Vitals pop is closed") expected_blood_pressure = "{sys} / {dia}".format(sys=sys_val, dia=dia_val) verify_entered_value_in_main_treatment_screen(value=expected_blood_pressure, vital=BLOOD_PRESSURE_TITLE, save=save) verify_entered_value_in_main_treatment_screen(value=heart_rate, vital=HEART_RATE_TITLE, save=save) test.endSection() def verify_color_of_entry(entry, vital_parameter, input_field): """ 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 = builtins.int(entry) if vital_parameter is SYSTOLIC_TEXT: if (entry < SYSTOLIC_LOWER_LIMIT) or (entry > SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT)) elif (entry >= SYSTOLIC_LOWER_LIMIT) and (entry <= SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, IN_RANGE_COLOR, "systolic value {} is in range of {} and {}".format(entry, SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT)) elif vital_parameter is DIASTOLIC_TEXT: if (entry < DIASTOLIC_LOWER_LIMIT) or (entry > DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color, OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT)) elif (entry >= DIASTOLIC_LOWER_LIMIT) and (entry <= DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color, IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT)) elif vital_parameter is HEART_RATE_TITLE: if (entry < HEART_RATE_LOWER_LIMIT) or (entry > HEART_RATE_UPPER_LIMIT): test.compare(input_field_color, OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT)) elif (entry >= HEART_RATE_LOWER_LIMIT) and (entry <= HEART_RATE_UPPER_LIMIT): test.compare(input_field_color,IN_RANGE_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT)) test.endSection() def verify_entered_value_in_main_treatment_screen(value, vital, save): """ method to verify the user entered value in main-treatment screen @param value: (int) user user entered value @param vital - (str) parameter name under which user is entering value (sys/dia/heart rate) @param input_field - (obj) object of input field @return N/A """ test.startSection("Verify the user entered {} value {} in main-treatment screen".format(vital, value)) if save: input_field = waitForObject(vitals_reading_obj(value)) entered_value = input_field.text value = str(value) test.compare(str(entered_value), value, "Expected {} value: {} should be equal to Actual {} value: {}".format(vital, value, vital, entered_value)) elif (save is False): if object.exists(vitals_reading_obj(value)) is False: test.log("Entered is not saved and is not updated in main-treatment screen") test.endSection() def test_patient_connection_instruction_screen(screen_indicator): for instruction_screen in (screen_indicator): mouseClick(waitForObject(names.names.o_PreTreatmentBase_rightImage_Image)) test.compare(str(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(str(waitForObjectExists(names.o_swipeview_tutorial_text).enabled, True, "Tutorial text should be enabled.")) test.compare(str(waitForObjectExists(names.o_swipeview_tutorial_text).text, config.TUTORIAL_TEXT[screen_indicator], "Tutorial text should be {msg}".format(msg=config.TUTORIAL_TEXT[screen_indicator]))) #verify_bullet_indicators(screen_indicator) if screen_indicator == 4: test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Continue_Text).enabled, False, "continue button should be disabled")) else: test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Continue_Text).enabled, True, "continue button should be disabled")) for instruction_screen in (screen_indicator): mouseClick(waitForObject(names.o_PreTreatmentBase_leftImage_Image)) 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) test.compare(waitForObject(names.o_PreTreatmentUltrafiltration_volumeSlider_Slider).value , (slider_value/10), "user adjusted slider value to -> "+ str(slider_value/10)) 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 value ->" +str(ultrafilteration_range)) 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 verify_bullet_indicators(indicator): test.verify((names.o_PreTreatmentBase_headStepBullet_StepBullet).visible, "Verify headstep bullet") test.verify((names.o_PreTreatmentBase_indicator_StepIndicator).enable, "Verified indicator") def reset_treatment_time_verification(vTotal): """ Method to reset and verify Actual time in seconds to Maximum & Minimum values on UI screen in seconds @param vTotal: (int) Total time in seconds """ mouseClick(waitForObject(names.o_PreTreatmentbase_skip_text)) 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.BP_TEXT, "BP title text should be :" + str(config.BP_TEXT)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_mmHg_Label).text, config.MMHG_TEXT, "BP unit should be " + str(config.MMHG_TEXT)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_Heart_Rate_Text).text, config.HR_TEXT, "HR text should be :" + str(config.HR_TEXT)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_BPM_Label).text, config.BPM_LABEL, "BP unit should be " + str(config.BPM_LABEL)) verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=SYSTOLIC_PRESSSURE_120, dia_val=DIASTOLIC_PRESSSURE_80, heart_rate=HEART_RATE_VAL_101, save=True) 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() test_patient_connection_instruction_screen(screen_indicator = 1) test_patient_connection_instruction_screen(screen_indicator = 2) test_patient_connection_instruction_screen(screen_indicator = 3) test_patient_connection_instruction_screen(screen_indicator = 4) snooze(10) utils.tstDone()