Index: tst_pre_treatment_priming/test.py =================================================================== diff -u -r5fc2cf1333ef13de0a5b547e8b029f664b263941 -r262cc42e2b0a0044bc0c698249b0da502a31766f --- tst_pre_treatment_priming/test.py (.../test.py) (revision 5fc2cf1333ef13de0a5b547e8b029f664b263941) +++ tst_pre_treatment_priming/test.py (.../test.py) (revision 262cc42e2b0a0044bc0c698249b0da502a31766f) @@ -9,11 +9,15 @@ hd_simulator = HDSimulator() -BEGIN_PRIME_TITLE = "Begin Prime" -PRIMING_TITLE = "Priming" -MAXIMUM_COUNTDOWN_TIME = 300 -MINIMUM_COUNTDOWN_TIME = 0 - +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 @@ -40,65 +44,122 @@ test.endSection() -def get_time(screen_title): + + + +def verify_dry_states(): """ - Method to return the current count down - in the application - @return time_text - (str) count down in the application + Method to simulating different states + of self dry test and verify the busy and + check indicator """ - parent_object = object.parent(waitForObjectExists(self_test_dry_check_list_text(screen_title))) - time_parent_children = object.children(parent_object) - progress_circle_parent = time_parent_children[4] - progress_circle_parent = object.children(progress_circle_parent) - progress_circle_parent = progress_circle_parent[0] - progress_circle_parent = object.children(progress_circle_parent) - progress_circle_children = object.children(progress_circle_parent[0]) - time_text = progress_circle_children[1] - return time_text.time + 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_countdown(screen_title): +def verify_the_indicators(indicator, steps): """ - Method to verify the count down - time in application + Method to verify the indicator + next to each check list steps + @param indicator - (str) expected indicator + @param steps - Expected steps """ - test.startSection("Verify the count down time in application") - for count_down in range(MINIMUM_COUNTDOWN_TIME, MAXIMUM_COUNTDOWN_TIME+1): - if screen_title == BEGIN_PRIME_TITLE: - hd_simulator.cmd_send_pre_treatment_self_test_dry_progress_data(total=300, countdown=count_down) - else: - hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(timeout=300, countdown=count_down) - actual_time = get_time(screen_title) - expected_time = convert_seconds_into_min_and_sec(count_down) - if count_down > MAXIMUM_COUNTDOWN_TIME or count_down < MINIMUM_COUNTDOWN_TIME: - test.xcompare(actual_time, expected_time, "{} should not display on progress circle".format(expected_time)) - else: - test.compare(actual_time, expected_time, "Actual count down time: {} should be equal to expected count down time {}".format(actual_time, expected_time)) - verify_the_progress(count_down) + 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_the_progress(count_down): +def verify_completion_message_and_indicator(completed): + """ + Method to verify the 'Self Test Complete!' + is displayed + @param completed - (bool) True/False """ - Method to verify the current progress - """ - test.startSection("Verifying the current progress") - current_progress = (waitForObjectExists(names.o_self_test_dry_progress)).progressValue - #Since progress value is equal maximum count down value - current count down value - expected_progress = MAXIMUM_COUNTDOWN_TIME - count_down - test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) + 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) - snooze(20) # hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(self, timeout: int, countdown: int)