# -*- coding: utf-8 -*-" import names import os from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from configuration import config from configuration import utility from dialin.common.hd_defs import HDOpModes, HDOpSubModes, PreTreatmentSampleWaterStates, PreTreatmentConsumableSelfTestStates, PreTreatmentNoCartSelfTestsStates, PreTreatmentCartridgeInstallStates, PreTreatmentDrySelfTestsStates, PreTreatmentPrimeStates, PreTreatmentRecircStates, PreTreatmentPatientConnectionStates from dialin.ui.utils import waitForGUI 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 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() for line in contents: length =len(line) if line[0] =="[": continue else: conf_data = line.split("=") 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): """ 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] 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") 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(): """ 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) 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 = read_data_from_conf_file() verify_instruction_watersample(instruction_list) verify_image_title_water_sample() utils.tstDone()