Index: tst_instructions_poc/test.py =================================================================== diff -u -rdc194f1ceb84a009dae78a5cb864c835223d4cd7 -r1b390e5fda312e84d17537775b419c7dff8dd99f --- tst_instructions_poc/test.py (.../test.py) (revision dc194f1ceb84a009dae78a5cb864c835223d4cd7) +++ tst_instructions_poc/test.py (.../test.py) (revision 1b390e5fda312e84d17537775b419c7dff8dd99f) @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*-" import names +import os + from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from configuration import config @@ -11,10 +13,24 @@ hd_simulator = HDSimulator() contents = [] instructions = [] +image_names = [] instruction_textobj = [names.o_instruction_ws_screen_one,names.o_instruction_ws_screen_two,names.o_instruction_ws_screen_three] conf_dict = {} -def verify_instruction(): +def get_text_obj(obj_name,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 + + +def read_data_from_conf_file(): + """ + 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: contents = conf_file.readlines() @@ -27,32 +43,48 @@ if length > 2: 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 def verify_instruction_watersample(instruction_list): - index = 0 -# test.log(str(instruction_list)) - for text_obj in instruction_textobj: + """ + 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.log(str(instruction_text)) if instruction_text[-1] == " ": instruction_text = instruction_text.rstrip() - test.compare(str(waitForObject(text_obj).text),instruction_text, "Instruction from water sample screen should be visible and matched") - index += 1 + test.compare(str(waitForObject(get_text_obj(text_obj,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)) + mouseClick(waitForObject(names.o_fail_button)) + test.endSection() + +def verify_image_title_water_sample(): + """ + 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) + for image in image_names: + if image in image_titles: + test.passes("Image "+ str(image) +" is present at given file location") + else: + test.fail("Image "+ str(image) +" is not present at given file location") + test.endSection() def main(): + utils.tstStart(__file__) startApplication(config.AUT_NAME) - test.startSection("Verify the water sample instruction") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_PRET.value,PreTreatmentSampleWaterStates.SAMPLE_WATER_SETUP_STATE.value) 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 = verify_instruction() + instruction_list = read_data_from_conf_file() verify_instruction_watersample(instruction_list) - - waitForGUI(5) - test.endSection() \ No newline at end of file + verify_image_title_water_sample() + utils.tstDone() + \ No newline at end of file