Index: tst_instructions_poc/test.py =================================================================== diff -u -r1b390e5fda312e84d17537775b419c7dff8dd99f -rc8021593406bed7d21e66ecfbec22762f9f0842b --- tst_instructions_poc/test.py (.../test.py) (revision 1b390e5fda312e84d17537775b419c7dff8dd99f) +++ tst_instructions_poc/test.py (.../test.py) (revision c8021593406bed7d21e66ecfbec22762f9f0842b) @@ -14,17 +14,21 @@ contents = [] instructions = [] image_names = [] -instruction_textobj = [names.o_instruction_ws_screen_one,names.o_instruction_ws_screen_two,names.o_instruction_ws_screen_three] +title_list = [] +count_of_instructions = [] +title_count_dict = {} conf_dict = {} +obj_names = [names.o_PreTreatmentBase_swipeview_SwipeView,names.o_PreTreatmentBase_swipeview_SwipeView_2] -def get_text_obj(obj_name,text): +def get_text_obj(screen_obj,text): """ To obtain a text object based on text provided @param obj_name: provides the object name on which the text must be present @returns a real name object """ - obj_name["text"] = text - return obj_name + names.o_instruction["container"] = screen_obj + names.o_instruction["text"] = text + return names.o_instruction def read_data_from_conf_file(): @@ -34,41 +38,62 @@ utils.waitForGUI(0.2) with open(utility.INSTRUCTION_CONF_LOCATION, 'r') as conf_file: contents = conf_file.readlines() + count = 0 + line_count = 0 for line in contents: length =len(line) + line_count += 1 if line[0] =="[": + title = line.split("^") + title_strip = title[1][:-2] + title_list.append(title_strip) 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])) image_names.append(conf_data[1].strip()) - return instructions + if line_count == len(contents): + count_of_instructions.append(count) + title_count_dict.update(dict(zip(title_list,count_of_instructions))) +# return instructions -def verify_instruction_watersample(instruction_list): +def verify_instruction(title,index): """ This method is used to verify the instructions from water sample screen @param - (str) list of instructions from Instruction.conf file """ - test.startSection("Verify the instructions from water sample screen") - for index,text_obj in enumerate(instruction_textobj): - instruction_text = instruction_list[index] +# test.startSection("Verify the instructions from water sample screen") +# test.log(str(instructions)) + for i in range((title_count_dict.get(title))): + instruction_text = instructions[index] + test.log(str(instruction_text)) + index += 1 + test.log(str(index)) if instruction_text[-1] == " ": instruction_text = instruction_text.rstrip() - test.compare(str(waitForObject(get_text_obj(text_obj,instruction_text)).text),instruction_text, "Instruction from water sample screen should be visible and matched") + test.log(str(instruction_text)) + test.compare(str(waitForObject(get_text_obj(obj_names[0],instruction_text)).text),instruction_text, "Instruction from water sample screen should be visible and matched") if object.exists(names.o_next_button): mouseClick(waitForObject(names.o_next_button)) if object.exists(names.o_fail_button): mouseClick(waitForObject(names.o_fail_button)) - test.endSection() - -def verify_image_title_water_sample(): + return index +# test.endSection() + +def verify_image_title_water_sample(image_names): """ This method is used to verify all the image titles from Instructions.conf file. """ test.startSection("Verify all the image titles from Instructions.conf file") image_titles = os.listdir(utility.IMAGE_FILE_LOCATION) + image_names = list(set(image_names)) for image in image_names: if image in image_titles: test.passes("Image "+ str(image) +" is present at given file location") @@ -83,8 +108,18 @@ hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=HDOpSubModes.SUBMODE_WAIT_FOR_TREATMENT.value, water_sample_state=PreTreatmentSampleWaterStates.SAMPLE_WATER_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) - instruction_list = read_data_from_conf_file() - verify_instruction_watersample(instruction_list) - verify_image_title_water_sample() + read_data_from_conf_file() + index = verify_instruction("Water Sample",index = 0) + index = verify_instruction("Water Sample Result",index = index) + index = verify_instruction("Water Sample Result Failed",index = index) + hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_PRET.value,PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_INSTALL_STATE.value) + 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) + test.log(str(obj_names[0])) + obj_names.pop(0) + test.log(str(obj_names[0])) + index = verify_instruction("Consumables Installation",index = index) +# verify_image_title_water_sample(image_names) utils.tstDone() \ No newline at end of file