# -*- coding: utf-8 -*-" import names from configuration.config import * from configuration.utility import * from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator hd_simulator = HDSimulator() PRE_TREATMENT_STEP = 4 SELF_TEST_DRY_STATES = {"DRY_SELF_TESTS_STATE" : 0, "DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE" : 1, "DRY_SELF_TESTS_USED_CARTIDGE_CHECK_STATE": 2, "DRY_SELF_TESTS_OCCLUSION_SENSORS_STATE": 3, "DRY_SELF_TESTS_PRESSURE_SENSORS_SETUP_STATE" : 4, "DRY_SELF_TESTS_PRESSURE_SENSORS_STATE" : 5, "DRY_SELF_TESTS_PRESSURE_SENSORS_NORMAL_STATE" : 6, "DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE" : 7, "DRY_SELF_TESTS_STOPPED_STATE" : 8, "DRY_SELF_TESTS_COMPLETE_STATE" : 9} PRIMING_STATES = {"HD_PRIME_START_STATE" : 0, "HD_PRIME_WAIT_FOR_USER_START_STATE" : 1, "HD_PRIME_SALINE_SETUP_STATE" : 2, "HD_PRIME_SALINE_PURGE_AIR_STATE" : 3, "HD_PRIME_SALINE_CIRC_BLOOD_CIRCUIT_STATE" : 4, "HD_PRIME_RESERVOIR_ONE_FILL_COMPLETE_STATE" : 5, "HD_PRIME_DIALYSATE_DIALYSER_STATE" : 6, "HD_PRIME_RESERVOIR_TWO_FILL_COMPLETE_STATE" : 7, "HD_PRIME_DIALYSATE_BYPASS_STATE" : 8, "HD_PRIME_WET_SELF_TESTS_STATE" : 9, "HD_PRIME_PAUSE" : 10, "HD_PRIME_COMPLETE" :11} RECIRCULATE_STATES = {"PRE_TREATMENT_RECIRC_STATE" : 0, "PRE_TREATMENT_RECIRC_STOPPED_STATE" : 1} TEST_DRY_STEPS = ["Used Cartridge Check", "Occlusion Sensors Check", "Pressure Sensors Check", "Syringe Pump Check"] PRIMING_STEPS = ["Blood Circuit Priming", "Dialysate Circuit Priming", "Wet Self Tests"] SELF_TEST_COMPLETION_MSG = "Self Test Complete!" PRIMING_COMPLETE_MSG = "Priming Complete!" def navigate_self_test_dry_screen(): """ Method to navigate to self test dry screen and verify the 'Begin Prime' title is displayed """ test.startSection("Navigating to self test dry screen and verify the 'Begin Prime' title is displayed") navigate_to_pretreatment_screen(5) title = (waitForObjectExists(self_test_dry_check_list_text(BEGIN_PRIME_TITLE))).text test.compare(title, BEGIN_PRIME_TITLE, "{} title should be displayed when user is navigating to self test dry screen".format(BEGIN_PRIME_TITLE)) page_step_indicator_verification(names.o_PreTreatmentStack_PreTreatmentPrimeStack_PreTreatmentPrimeStack, PRE_TREATMENT_STEP) test.endSection() def navigate_to_priming_screen(): """ Method to navigate to priming screen and verify the 'Priming' title is displayed """ test.startSection("Navigating to priming screen and verify the begin 'Priming' title is displayed") navigate_to_pretreatment_screen(6) title = (waitForObject(self_test_dry_check_list_text(PRIMING_TITLE))).text test.compare(title, PRIMING_TITLE, "{} title should be displayed when user is navigating to 'Priming' screen".format(PRIMING_TITLE)) page_step_indicator_verification(names.o_PreTreatmentStack_PreTreatmentPrimeStack_PreTreatmentPrimeStack, PRE_TREATMENT_STEP) test.endSection() def verify_dry_states(): """ Method to simulating different states of self dry test and verify the busy and check indicator """ test.startSection("Simulating different states of self dry test and verifying the busy and check indicator") for state, index in SELF_TEST_DRY_STATES.items(): test.startSection("Passing {} state".format(state)) hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=5, water_sample_state=0, consumables_self_test_state=0, no_cartridge_self_test_state=0, installation_state=0, dry_self_test_state=index, prime_state=0, recirculate_state=0, patient_connection_state=0) if (state == "DRY_SELF_TESTS_STATE") or (state == "DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE"): verify_the_indicators(None, TEST_DRY_STEPS) elif state == "DRY_SELF_TESTS_USED_CARTIDGE_CHECK_STATE": verify_the_indicators(BUSY, "Used Cartridge Check") elif state == "DRY_SELF_TESTS_OCCLUSION_SENSORS_STATE": verify_the_indicators(CHECK, "Used Cartridge Check") verify_the_indicators(BUSY, "Occlusion Sensors Check") elif (state == "DRY_SELF_TESTS_PRESSURE_SENSORS_SETUP_STATE") or (state == "DRY_SELF_TESTS_PRESSURE_SENSORS_STATE") or (state == "DRY_SELF_TESTS_PRESSURE_SENSORS_NORMAL_STATE"): verify_the_indicators(CHECK, "Used Cartridge Check") verify_the_indicators(CHECK, "Occlusion Sensors Check") verify_the_indicators(BUSY, "Pressure Sensors Check") elif state == "DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE": verify_the_indicators(CHECK, "Used Cartridge Check") verify_the_indicators(CHECK, "Occlusion Sensors Check") verify_the_indicators(CHECK, "Pressure Sensors Check") verify_the_indicators(BUSY, "Syringe Pump Check") elif state == "DRY_SELF_TESTS_STOPPED_STATE": verify_the_indicators(CHECK, "Used Cartridge Check") verify_the_indicators(CHECK, "Occlusion Sensors Check") verify_the_indicators(CHECK, "Pressure Sensors Check") verify_the_indicators(CHECK, "Syringe Pump Check") verify_completion_message_and_indicator(False, SELF_TEST_COMPLETION_MSG) else: verify_the_indicators(CHECK, "Used Cartridge Check") verify_the_indicators(CHECK, "Occlusion Sensors Check") verify_the_indicators(CHECK, "Pressure Sensors Check") verify_the_indicators(BUSY, "Syringe Pump Check") verify_completion_message_and_indicator(True, SELF_TEST_COMPLETION_MSG) test.endSection() test.endSection() def verify_priming_recirculate_states(): """ Method to simulating different states of priming recirculate and verify the busy and check indicator """ test.startSection("Simulating different states of priming recirculate states and verifying the busy and check indicator") for state, index in RECIRCULATE_STATES.items(): test.startSection("Passing {} state".format(state)) hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=7, water_sample_state=0, consumables_self_test_state=0, no_cartridge_self_test_state=0, installation_state=0, dry_self_test_state=0, prime_state=0, recirculate_state=index, patient_connection_state=0) verify_the_indicators(CHECK, "Blood Circuit Priming") verify_the_indicators(CHECK, "Dialysate Circuit Priming") verify_the_indicators(BUSY, "Wet Self Tests") verify_completion_message_and_indicator(True, PRIMING_COMPLETE_MSG) verify_the_continue_button(ENABLED) test.endSection() test.endSection() def verify_priming_states(): """ Method to simulating different states of priming and verify the busy and check indicator """ test.startSection("Simulating different states of priming and verifying the busy and check indicator") for state, index in PRIMING_STATES.items(): test.startSection("Passing {} state".format(state)) hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=6, water_sample_state=0, consumables_self_test_state=0, no_cartridge_self_test_state=0, installation_state=0, dry_self_test_state=0, prime_state=index, recirculate_state=0, patient_connection_state=0) if (state == "HD_PRIME_START_STATE") or (state == "HD_PRIME_WAIT_FOR_USER_START_STATE") or (state == "HD_PRIME_SALINE_SETUP_STATE") or (state == "HD_PRIME_SALINE_PURGE_AIR_STATE"): verify_the_indicators(indicator=None, steps=PRIMING_STEPS) if state == "HD_PRIME_WAIT_FOR_USER_START_STATE": verify_the_start_priming_button(ENABLED) else: verify_the_start_priming_button(DISABLED) verify_the_continue_button(DISABLED) elif (state == "HD_PRIME_SALINE_CIRC_BLOOD_CIRCUIT_STATE") or (state == "HD_PRIME_RESERVOIR_ONE_FILL_COMPLETE_STATE") or (state == "HD_PRIME_DIALYSATE_DIALYSER_STATE"): verify_the_indicators(BUSY, "Blood Circuit Priming") verify_the_start_priming_button(DISABLED) verify_the_continue_button(DISABLED) elif (state == "HD_PRIME_RESERVOIR_TWO_FILL_COMPLETE_STATE") or (state == "HD_PRIME_DIALYSATE_BYPASS_STATE"): verify_the_indicators(CHECK, "Blood Circuit Priming") verify_the_indicators(BUSY, "Dialysate Circuit Priming") verify_the_start_priming_button(DISABLED) verify_the_continue_button(DISABLED) elif (state == "HD_PRIME_WET_SELF_TESTS_STATE") or (state == "HD_PRIME_PAUSE"): verify_the_indicators(CHECK, "Blood Circuit Priming") verify_the_indicators(CHECK, "Dialysate Circuit Priming") verify_the_start_priming_button(DISABLED) verify_the_continue_button(DISABLED) else: verify_the_indicators(CHECK, "Blood Circuit Priming") verify_the_indicators(CHECK, "Dialysate Circuit Priming") verify_the_indicators(BUSY, "Wet Self Tests") verify_the_start_priming_button(DISABLED) verify_completion_message_and_indicator(False, PRIMING_COMPLETE_MSG) verify_the_continue_button(DISABLED) test.endSection() test.endSection() def get_indicators(step): """ Method to return the busy and check indicator object of expected step @param step - (str) expected step @return indicators - (obj) list of busy and check indicator """ parent_obj = object.parent(waitForObjectExists(self_test_dry_check_list_text(step))) children_obj = object.children(parent_obj) indicator_parent = children_obj[2] indicators = object.children(indicator_parent) return indicators def verify_the_indicators(indicator, steps): """ Method to verify the indicator next to each check list steps @param indicator - (str) expected indicator @param steps - (str) Expected steps """ test.startSection("Verify indicator is displayed for {}".format(steps)) if indicator != None: busy_indicator, check_indicator = get_indicators(steps) if indicator is BUSY: test.compare(busy_indicator.visible, VISIBLE, "{} indicator should display next to the {}".format(indicator, steps)) elif indicator is CHECK: test.compare(check_indicator.visible, VISIBLE, "{} indicator should display next to the {}".format(indicator, steps)) else: for step in steps: busy_indicator, check_indicator = get_indicators(step) test.compare(busy_indicator.visible, NOT_VISIBLE, "No indicator should display next to the {}".format(step)) test.compare(check_indicator.visible, NOT_VISIBLE, "No indicator should display next to the {}".format(step)) test.endSection() def verify_completion_message_and_indicator(completed, msg): """ Method to verify the completion message is displayed @param completed - (bool) True/False @param msg - (str) completion message """ test.startSection("verify the {} is displayed".format(msg)) check_indicator = object.children(findObject(names.o_self_test_dry_progress_circle)) check_indicator = objectMap.realName(check_indicator[2]) if completed: completion_msg = waitForObjectExists(self_test_dry_check_list_text(msg)) test.compare(completion_msg.visible, VISIBLE, "{} message should be displayed".format(msg)) test.compare(completion_msg.text, msg, "Completion message should be {}".format(msg)) if object.exists(check_indicator): test.passes("Check indicator should display on progress circle upon completion") else: if object.exists(self_test_dry_check_list_text(msg)) is False: test.passes("{} message should not display".format(msg)) test.endSection() def verify_the_start_priming_button(expected_state): """ Method to verify the 'Start Prime' button is enabled @param expected_state - (bool) True/False """ test.startSection("Verifying the 'Start Prime' button is enabled or disabled") start_prime_btn = waitForObjectExists(names.o_start_prime_btn) if expected_state: test.compare(start_prime_btn.enabled, ENABLED, "'Start Prime' should be enabled") else: test.compare(start_prime_btn.enabled, DISABLED, "'Start Prime' should be disabled") test.endSection() def verify_the_continue_button(expected_state): """ Method to verify the 'Continue' button is enabled @param expected_state - (bool) True/False """ test.startSection("Verifying the 'Continue' button is enabled or disabled") continue_btn = waitForObjectExists(names.o_continue_btn) if expected_state: test.compare(continue_btn.enabled, ENABLED, "'Continue' should be enabled") else: test.compare(continue_btn.enabled, DISABLED, "'Continue' should be disabled") test.endSection() def main(): utils.tstStart(__file__) startApplication(AUT_NAME) test.startSection("Verifying 'Self Dry Test' screen") navigate_self_test_dry_screen() verify_the_countdown(BEGIN_PRIME_TITLE) verify_dry_states() test.endSection() test.startSection("Verifying 'Priming' screen") navigate_to_priming_screen() verify_the_countdown(PRIMING_TITLE) verify_priming_states() verify_priming_recirculate_states() test.endSection() utils.tstDone()