# -*- 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. # section import names from dialin.ui.hd_simulator import HDSimulator from dialin.ui.dg_simulator import DGSimulator from dialin.ui import utils from configuration import config, utility hd_simulator = HDSimulator() 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, uf_value): """ 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 = uf_value) 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 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 verification_Bullets_text(): 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 """ hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(0,vTotal) test.compare(waitForObjectExists(names.Time_text).parent.maximum, vTotal, "Reset maximum value and compare it expected value{}".format(vTotal)) test.compare(waitForObjectExists(names.Time_text).parent.minimum, 0, "Reset minimun value and compare it expected value{}".format(0)) 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_sub_mode = 8) #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() #hd_simulator.cmd_set_treatment_adjust_ultrafiltration_accepted(state= 1) hd_simulator.cmd_send_uf_treatment_response(accepted = 0, reason = 6, volume = 70) snooze(10) utils.waitForGUI(3) utils.tstDone()