# -*- 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 PRE_TREATMENT_STEPS = 5 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" : 500}, "OPTION_7" : {"uf_maximum" : 680, "uf_minimum" : 450}, "OPTION_8" : {"uf_maximum" : 480, "uf_minimum" : 380}, "OPTION_9" : {"uf_maximum" : 390, "uf_minimum" : 100}, "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 @param target: (int) saline bolus Target volume @param saline_states: (int) saline bolus transition State @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 = findObject(names.o_treatment_notification_bar) test.compare(rejection_message.text, config.REJECTION_REASON[rejection], "expected rejection {msg} displayed".format(msg=config.REJECTION_REASON[rejection])) 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 verify_filter_flush_text(): """ Verify Filter Flush Text on UI Screen """ test.log("Verifying the text 'Filter Flush'") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Filter_Flush_Text).text),FILTER_FLUSH_TEXT, "Verified Filter Flush text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Create_Text).text),CREATE, "Verified Create text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Sample_Text).text),SAMPLE, "Verified Sample text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Consumables_Text).text),CONSUMABLES, "Verified Consumables text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Disposables_Text).text),DISPOSABLES, "Verified Disposables text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Prime_Text).text),PRIME, "Verified PRIME text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Ultrafiltration_Text).text),ULTRAFILTERATION, "Verified Ultrafilteration text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_BP_HR_Text).text),BP_HR, "Verified BP/HR text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Connection_Text).text),CONNECTION, "Verified Connection text") test.compare(str(waitForObjectExists(names.o_PreTreatmentBase_Start_Text).text),START, "Verified Start text") 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)) 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_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).value), uf_value, "uf set value should be :" + str(uf_value)) # test.compare(utils.l2ml(waitForObjectExists(names.o_volumeSlider_slider).maximum), max_uf, "maximum uf value should be :" + str(max_uf)) # test.compare(utils.l2ml(waitForObjectExists(names.o_volumeSlider_slider).minimum), min_uf, "minimum uf value should be :" + str(min_uf)) 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 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_patient_connection(PRE_TREATMENT_PATIENT_CONNECTION_MODE) #utility.page_step_indicator_verification(PRE_TREATMENT_STEPS, names.ultrafilteration_text) 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"]) test_rejection_message_patient_connection(accept_status = False) hd_simulator.cmd_send_uf_treatment_response(accepted = True, reason = 0, volume = config.UF_VALID_RANGE) #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()