# -*- 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() 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} TEST_DRY_STEPS = ["Used Cartridge Check", "Occlusion Sensors Check", "Pressure Sensors Check", "Syringe Pump Check"] SELF_TEST_COMPLETION_MSG = "Self Test 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(mode=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)) 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(mode=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)) 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(indicator=None, steps=TEST_DRY_STEPS) elif state == "DRY_SELF_TESTS_USED_CARTIDGE_CHECK_STATE": verify_the_indicators(indicator=BUSY, steps="Used Cartridge Check") elif state == "DRY_SELF_TESTS_OCCLUSION_SENSORS_STATE": verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") verify_the_indicators(indicator=BUSY, steps="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(indicator=CHECK, steps="Used Cartridge Check") verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") verify_the_indicators(indicator=BUSY, steps= "Pressure Sensors Check") elif state == "DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE": verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") verify_the_indicators(indicator=CHECK, steps="Pressure Sensors Check") verify_the_indicators(indicator=BUSY, steps="Syringe Pump Check") elif state == "DRY_SELF_TESTS_STOPPED_STATE": verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") verify_the_indicators(indicator=CHECK, steps="Pressure Sensors Check") verify_the_indicators(indicator=CHECK, steps="Syringe Pump Check") verify_completion_message_and_indicator(False) else: verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") verify_the_indicators(indicator=CHECK, steps="Pressure Sensors Check") verify_the_indicators(indicator=BUSY, steps="Syringe Pump Check") verify_completion_message_and_indicator(True) 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 """ 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 - 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): """ Method to verify the 'Self Test Complete!' is displayed @param completed - (bool) True/False """ test.startSection("verify the 'Self Test Complete!' is displayed") 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(SELF_TEST_COMPLETION_MSG)) test.compare(completion_msg.visible, VISIBLE, "{} message should be displayed".format(SELF_TEST_COMPLETION_MSG)) test.compare(completion_msg.text, SELF_TEST_COMPLETION_MSG, "Completion message should be {}".format(SELF_TEST_COMPLETION_MSG)) if object.exists(check_indicator): test.passes("Check indicator should display on progress circle upon completion of 'Self test'") else: if object.exists(self_test_dry_check_list_text(SELF_TEST_COMPLETION_MSG)) is False: test.passes("{} message should not display".format(SELF_TEST_COMPLETION_MSG)) test.endSection() def main(): utils.tstStart(__file__) startApplication(AUT_NAME) navigate_self_test_dry_screen() verify_the_countdown(BEGIN_PRIME_TITLE) verify_dry_states() navigate_to_priming_screen() verify_the_countdown(PRIMING_TITLE) # hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(self, timeout: int, countdown: int)