Index: tst_instructions_poc/test.py =================================================================== diff -u -rffd3e6dd750e25fa95d256c8284d54e55ad1ea87 -r535df219a0721d69e25f36e9a24c98e7b59394b3 --- tst_instructions_poc/test.py (.../test.py) (revision ffd3e6dd750e25fa95d256c8284d54e55ad1ea87) +++ tst_instructions_poc/test.py (.../test.py) (revision 535df219a0721d69e25f36e9a24c98e7b59394b3) @@ -9,20 +9,18 @@ from configuration import utility from dialin.common.hd_defs import HDOpModes, HDOpSubModes, PreTreatmentSubModes, PreTreatmentSampleWaterStates, PreTreatmentConsumableSelfTestStates, PreTreatmentNoCartSelfTestsStates, PreTreatmentCartridgeInstallStates, PreTreatmentDrySelfTestsStates, PreTreatmentPrimeStates, PreTreatmentRecircStates, PreTreatmentPatientConnectionStates, TreatmentStates, UFStates, SalineBolusStates, HeparinStates, TreatmentRinsebackStates, PreTreatmentRecircStates, TreatmentBloodPrimeStates, TreatmentEndStates, TreatmentStopStates, TreatmentDialysisStates -from dialin.ui.utils import waitForGUI - hd_simulator = HDSimulator() ven_low = 40 ven_high = 400 art_low = -240 art_high = -20 +first_index = 0 contents = [] instructions = [] image_names = [] title_list = [] count_of_instructions = [] title_count_dict = {} -conf_dict = {} image_list_from_location = os.listdir(config.EXPECTED_IMAGE_LOCATION) text_obj_names = [names.o_PreTreatmentBase_swipeview_SwipeView_WaterSample,names.o_PreTreatmentBase_swipeview_SwipeView_Consumables,names.o_preTreatmentDisposablesCartridgeInstallation_swipeview_SwipeView,names.o_preTreatmentDisposablesCartridgeConnetion_swipeview_SwipeView,names.o_PreTreatmentBase_swipeview_SwipeView,names.o_preTreatmentDisposablesSalineBag_swipeview_SwipeView,names.o_PreTreatmentBase_swipeview_SwipeView_3,names.o_EndTreatmentRinsebackInit_swipeview_SwipeView,names.o_EndTreatmentRinsebackComplete_swipeview_SwipeView,names.o_patientDisconnectionConfirm_swipeview_SwipeView,names.o_disposablesRemovalConfirm_swipeview_SwipeView,names.o_EndTreatmentBase_swipeview_SwipeView,names.o_disinfect_swipeview_SwipeView] rightarrow_obj_names = [names.o_preTreatmentConsumablesStack_PreTreatmentBase_TreatmentFlowBase,names.o_preTreatmentDisposablesStack_preTreatmentDisposablesCartridgeInstallation_TreatmentFlowBase,names.o_preTreatmentDisposablesStack_preTreatmentDisposablesCartridgeConnetion_TreatmentFlowBase,names.o_PreTreatmentStack_preTreatmentDisposablesStack_PreTreatmentDisposablesStack,names.o_pretreatmentConnectionStack_PreTreatmentBase_TreatmentFlowBase,names.o_EndTreatmentRinsebackStack_EndTreatmentRinsebackInit_EndTreatmentRinsebackInit,names.o_PostTreatmentStack_patientDisconnectionConfirm_TreatmentFlowBase,names.o_PostTreatmentStack_disposablesRemovalConfirm_TreatmentFlowBase,names.o_EndTreatmentRecirculateStack_EndTreatmentBase_EndTreatmentBase,names.o_DisinfectStack_disinfect_TreatmentFlowBase] @@ -63,7 +61,7 @@ This method is used to read the data from Instructions.conf file. """ utils.waitForGUI(0.2) - with open(utility.INSTRUCTION_CONF_LOCATION, 'r') as conf_file: + with open(config.INSTRUCTION_CONF_LOCATION, 'r') as conf_file: contents = conf_file.readlines() count = 0 line_count = 0 @@ -77,39 +75,42 @@ continue else: conf_data = line.split("=") - if length <= 2: - if count > 0: - count_of_instructions.append(count) - count = 0 if length > 2: count += 1 - conf_dict.update([(conf_data[1],conf_data[0])]) - instructions.append(conf_dict.get(conf_data[1])) + instructions.append(conf_data[0]) image_names.append(conf_data[1].strip()) if line_count == len(contents): count_of_instructions.append(count) + else: + if count > 0: + count_of_instructions.append(count) + count = 0 title_count_dict.update(dict(zip(title_list,count_of_instructions))) def verify_instruction_and_image(title,index): """ This method is used to verify the instruction and image on present screen @param - (str) title: screen title @param - (int) index: index of data from Instructions.conf file + @return - (int) index """ test.startSection("Verifying instruction and image from " +title+ " screen") - for i in range((title_count_dict.get(title))): + for count in range(title_count_dict.get(title)): instruction_text = instructions[index] image_text = image_names[index] instruction_text = instruction_text.replace('\\n','\n') index += 1 + #to remove last empty character from the string if instruction_text[-1] == " ": instruction_text = instruction_text.rstrip() image_source = waitForObjectExists(get_img_obj(text_obj_names[0],"{}{}".format(config.IMAGE_LOCATION, image_text))).source.path test.compare(str(waitForObject(get_text_obj(text_obj_names[0],instruction_text)).text),instruction_text, "Instruction from " +title+ " screen is visible and matched") + #appends .png extension to image names,if not present if not(str(image_source).endswith(".png")): image_source = "{}{}".format(image_source,".png") if not(str(image_text).endswith(".png")): image_text = str(image_text) + ".png" + #to verify if image name mentioned in instructions.conf file is present at location if image_text in image_list_from_location: test.compare(str(image_source),"{}{}".format(config.EXPECTED_IMAGE_LOCATION, image_text), "Image from " +title+ " screen is visible and matched") else: @@ -313,15 +314,15 @@ index = verify_instruction_and_image("Water Sample",index = 0) index = verify_instruction_and_image("Water Sample Result",index = index) index = verify_instruction_and_image("Water Sample Result Failed",index = index) + text_obj_names.pop(first_index) test.endSection() test.startSection("Navigating to Pre-Treatment Consumables screen") hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=HDOpSubModes.SUBMODE_WAIT_FOR_DISINFECT.value, water_sample_state=PreTreatmentSampleWaterStates.SAMPLE_WATER_SETUP_STATE.value,consumables_self_test_state=PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_INSTALL_STATE.value, no_cartridge_self_test_state=PreTreatmentNoCartSelfTestsStates.NO_CART_SELF_TESTS_START_STATE.value,installation_state=PreTreatmentCartridgeInstallStates.CARTRIDGE_INSTALL_STATE.value, dry_self_test_state=PreTreatmentDrySelfTestsStates.DRY_SELF_TESTS_START_STATE.value, prime_state=PreTreatmentPrimeStates.HD_PRIME_START_STATE.value,recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PATIENT_CONNECTION_STATE.value) - text_obj_names.pop(0) index = verify_instruction_and_image("Consumables Installation",index = index) - rightarrow_obj_names.pop(0) + rightarrow_obj_names.pop(first_index) test.endSection() test.startSection("Method to navigate to create custom treatment to set all parameters ") @@ -343,24 +344,24 @@ prime_state=PreTreatmentPrimeStates.HD_PRIME_START_STATE.value, recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PATIENT_CONNECTION_STATE.value) - text_obj_names.pop(0) + text_obj_names.pop(first_index) index = verify_instruction_and_image("Cartridge Installation",index = index) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.log("Clicking on next button in Cartridge Installation instruction page") mouseClick(waitForObjectExists(names.o_next_button_cartridge_installation)) index = verify_instruction_and_image("Cartridge Connection",index = index) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.log("Clicking on next button in Cartridge Connection instruction page") mouseClick(waitForObjectExists(names.o_next_button_cartridge_connection)) index = verify_instruction_and_image("Heparin Syringe",index = index) - text_obj_names.pop(0) + text_obj_names.pop(first_index) test.log("Clicking on next button in Heparin Syringe instruction page") mouseClick(waitForObjectExists(names.o_next_button_heparinsyringe)) index = verify_instruction_and_image("Saline Bag",index = index) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.endSection() test.log("Navigating to Pre-Treatment Ultrafiltration screen") @@ -383,16 +384,16 @@ test.startSection("Navigating to Pre-Treatment Start screen") hd_simulator.cmd_send_pre_treatment_patient_connection_confirm_response(accepted=True, reason=0) index = verify_instruction_and_image("Start Treatment",index = index) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.endSection() test.startSection("Navigating to End Treatment Rinseback Setup screen") hd_simulator.cmd_set_treatment_states_data(sub_mode = TreatmentStates.TREATMENT_RINSEBACK_STATE.value, uf_state = UFStates.UF_START_STATE.value, saline_state = SalineBolusStates.SALINE_BOLUS_STATE_IDLE.value, heparin_state = HeparinStates.HEPARIN_STATE_OFF.value, rinseback_state = TreatmentRinsebackStates.RINSEBACK_STOP_INIT_STATE.value, recirculate_state = PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, blood_prime_state = TreatmentBloodPrimeStates.BLOOD_PRIME_RAMP_STATE.value, treatment_end_state = TreatmentEndStates.TREATMENT_END_WAIT_FOR_RINSEBACK_STATE.value, treatment_stop_state = TreatmentStopStates.TREATMENT_STOP_RECIRC_STATE.value, dialysis_state = TreatmentDialysisStates.DIALYSIS_START_STATE.value) index = verify_instruction_and_image("Rinseback Setup",index = index) - text_obj_names.pop(0) + text_obj_names.pop(first_index) test.endSection() test.startSection("Navigating to End Treatment Rinseback Complete screen") @@ -402,23 +403,23 @@ index = verify_instruction_and_image("Rinseback Complete",index = index) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.endSection() test.startSection("Navigating to Post Treatment Disconnection screen") hd_simulator.cmd_send_hd_operation_mode(op_mode = HDOpModes.MODE_POST.value , sub_mode = HDOpSubModes.SUBMODE_START.value) index = verify_instruction_and_image("Patient Disconnection",index = index) mouseClick(waitForObject(names.o_confirm_button_patient_disconnection)) mouseClick(waitForObject(names.o_next_button_review)) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.endSection() test.startSection("Navigating to Post Treatment Disposables screen") index = verify_instruction_and_image("Disposables Removal",index = index) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.endSection() test.startSection("Navigating to End Treatment Recirculate screen") @@ -428,8 +429,8 @@ index = verify_instruction_and_image("Recirculate",index = index) - text_obj_names.pop(0) - rightarrow_obj_names.pop(0) + text_obj_names.pop(first_index) + rightarrow_obj_names.pop(first_index) test.endSection() test.startSection("Navigating to Standby Disinfection screen")