Index: tst_instructions_poc/test.py =================================================================== diff -u -ref981744e6899b22a40fef4a8d74db9a4e930575 -r819ca4ef0dea8f3da4fd513f2b58f81fcc931dc9 --- tst_instructions_poc/test.py (.../test.py) (revision ef981744e6899b22a40fef4a8d74db9a4e930575) +++ tst_instructions_poc/test.py (.../test.py) (revision 819ca4ef0dea8f3da4fd513f2b58f81fcc931dc9) @@ -31,9 +31,8 @@ art_high = -20 first_index = 0 contents = [] -instructions = [] -image_names = [] title_list = [] +instr_with_title = {} count_of_instructions = [] title_count_dict = {} IMAGE_READY = 1 @@ -118,36 +117,36 @@ title = line.split("^") title_strip = title[1][:-2] title_list.append(title_strip) + instr_with_title[title_strip] = { "title" : title_strip, "instruction_set" : []} continue elif "#" not in line: conf_data = line.split("=") - print(f"~{count}~~{conf_data}~~~") + print(f"~~~{conf_data}~~~") if length > 2: count += 1 - instructions.append(conf_data[0]) - image_names.append(conf_data[1].strip()) + instr_with_title[title_strip]["instruction_set"].append({"instruction":conf_data[0], "instruction_image" : 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))) + # title_count_dict.update(dict(zip(title_list,count_of_instructions))) -def verify_instruction_and_image(title,index,textObjectName, rightArrowObject): +def verify_instruction_and_image(title, textObjectName, rightArrowObject): """ 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 count in range(title_count_dict.get(title)): + #traverse through the list of instruction text and image of the corresponding title + number_of_instructions = len(instr_with_title[title]["instruction_set"]) + for count in range(number_of_instructions): test.log(f"********************Instr Page count {title_count_dict.get(title)}") - instruction_text = instructions[index] - image_text = image_names[index] + instruction_text = instr_with_title[title]["instruction_set"][count]["instruction"] + image_text = instr_with_title[title]["instruction_set"][count]["instruction_image"] 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() @@ -163,7 +162,6 @@ if object.exists(get_rightarrow_obj(rightArrowObject)): mouseClick(waitForObject(get_rightarrow_obj(rightArrowObject))) test.endSection() - return index def test_sliderArrows(sliderObject = None, occurenceIndex = 0, currentValue = 0, changeAmount = 0, valuesKey = "", configStr = ""): """ @@ -404,9 +402,9 @@ no_cartridge_self_test_state=PreTreatmentNoCartSelfTestStates.NO_CART_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_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_WAIT_FOR_USER_START_STATE.value,recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PRE_TREATMENT_PAT_CONN_WAIT_FOR_UF_VOL_STATE.value, wet_selftests_state=PreTreatmentWetSelfTestStates.WET_SELF_TESTS_START_STATE.value, pretreatment_rsrvr_state=HDReservoirStates.TREATMENT_RESERVOIR_MGMT_START_STATE.value ) - index = verify_instruction_and_image("Water Sample",index = 0, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) - index = verify_instruction_and_image("Water Sample Result",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) - index = verify_instruction_and_image("Water Sample Result Failed",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Water Sample", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Water Sample Result", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Water Sample Result Failed", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() @@ -418,7 +416,7 @@ no_cartridge_self_test_state=PreTreatmentNoCartSelfTestStates.NO_CART_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_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_WAIT_FOR_USER_START_STATE.value,recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PRE_TREATMENT_PAT_CONN_WAIT_FOR_UF_VOL_STATE.value, wet_selftests_state=PreTreatmentWetSelfTestStates.WET_SELF_TESTS_START_STATE.value, pretreatment_rsrvr_state=HDReservoirStates.TREATMENT_RESERVOIR_MGMT_START_STATE.value) - index = verify_instruction_and_image("Consumables Installation",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Consumables Installation", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() # advance the title object @@ -449,15 +447,15 @@ wet_selftests_state=PreTreatmentWetSelfTestStates.WET_SELF_TESTS_START_STATE.value, pretreatment_rsrvr_state=HDReservoirStates.TREATMENT_RESERVOIR_MGMT_START_STATE.value) - index = verify_instruction_and_image("Cartridge Installation",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Cartridge Installation", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) # advance the title and arrow name # instructionScreenObject = text_obj_names.pop(first_index) instructionRightArrow = rightarrow_obj_names.pop(first_index) instructionScreenObject = text_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, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Cartridge Connection", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) # advance the title and arrow name instructionScreenObject = text_obj_names.pop(first_index) @@ -466,9 +464,10 @@ mouseClick(waitForObjectExists(names.o_next_button_cartridge_connection)) # Update instruction text to reflect expected value in instructions string - instructions[20] = re.sub("{.*?}", "0.1mL", instructions[20] ) + heparinInstruction = instr_with_title["Heparin Syringe"]["instruction_set"][0]["instruction"] + instr_with_title["Heparin Syringe"]["instruction_set"][0]["instruction"] = re.sub("{.*?}", "0.1mL", heparinInstruction) hd_simulator.cmd_send_heparin_response(syringePumpVolumeDelivered = 0.2, syringePumpVolumeRequired = 0.1) - index = verify_instruction_and_image("Heparin Syringe",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Heparin Syringe", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.log("Clicking on next button in Heparin Syringe instruction page") mouseClick(waitForObjectExists(names.o_next_button_heparinsyringe)) @@ -477,7 +476,7 @@ instructionScreenObject = text_obj_names.pop(first_index) instructionRightArrow = rightarrow_obj_names.pop(first_index) # index += title_count_dict.get("Heparin Syringe") #skipped Heparin Syringe instructions - index = verify_instruction_and_image("Saline Bag",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Saline Bag", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() @@ -502,15 +501,15 @@ # test.log("Clicking on skip button in BP/HR screen") # mouseClick(waitForObject(names.o_skip_button)) test.startSection("Navigating to Pre-Treatment Patient Connection screen") - index = verify_instruction_and_image("Patient Connection",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Patient Connection", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() # advance the title and arrow name instructionScreenObject = text_obj_names.pop(first_index) instructionRightArrow = rightarrow_obj_names.pop(first_index) 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, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Start Treatment", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() # advance the title and arrow name @@ -521,7 +520,7 @@ hd_simulator.cmd_set_treatment_states_data(sub_mode = TreatmentStates.TREATMENT_RINSEBACK_STATE.value, uf_state = UFStates.UF_PAUSED_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, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Rinseback Setup", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() # advance the title and arrow name @@ -533,15 +532,15 @@ 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 Complete",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Rinseback Complete", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() # advance the title and arrow name instructionScreenObject = text_obj_names.pop(first_index) instructionRightArrow = rightarrow_obj_names.pop(first_index) test.startSection("Navigating to Post Treatment Disconnection screen") hd_simulator.cmd_send_hd_operation_mode(op_mode = HDOpModes.MODE_POST.value , sub_mode = HDInitStates.POST_STATE_START.value) - index = verify_instruction_and_image("Patient Disconnection",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Patient Disconnection", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) mouseClick(waitForObject(names.o_confirm_button_patient_disconnection)) mouseClick(waitForObject(names.o_next_button_review)) test.endSection() @@ -553,7 +552,7 @@ instructionScreenObject = text_obj_names.pop(first_index) instructionRightArrow = rightarrow_obj_names.pop(first_index) test.startSection("Navigating to Post Treatment Disposables screen") - index = verify_instruction_and_image("Disposables Removal",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Disposables Removal", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() # advance the title and arrow name @@ -563,7 +562,7 @@ hd_simulator.cmd_set_treatment_states_data(sub_mode = TreatmentStates.TREATMENT_RECIRC_STATE.value, uf_state = UFStates.UF_PAUSED_STATE.value, saline_state = SalineBolusStates.SALINE_BOLUS_STATE_IDLE.value, heparin_state = HeparinStates.HEPARIN_STATE_OFF.value, rinseback_state = TreatmentRinsebackStates.RINSEBACK_STOP_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("Recirculate Disconnect",index = index, textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) + verify_instruction_and_image("Recirculate Disconnect", textObjectName = instructionScreenObject, rightArrowObject = instructionRightArrow) test.endSection() #TODO :- Disinfect verification