Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r5c9825f73e3d8daf6070b64d2c54cf8da61cbef4 -rba1474dc5c7f4efa5eaca5a840ab8d51a1c5c438 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 5c9825f73e3d8daf6070b64d2c54cf8da61cbef4) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision ba1474dc5c7f4efa5eaca5a840ab8d51a1c5c438) @@ -11,18 +11,17 @@ # ############################################################################ +import builtins import csv import glob import math -import object import names -import sys -import builtins -import names +import object import os -import test -import time +import sys import squish +import time +import test from builtins import format from builtins import int as pyInt @@ -41,43 +40,6 @@ def color_verification(exp_val = "Red", act_val = "#c53b33"): test.compare(config.COLOR_CODES[color_name],(act_val.color[name])) - -def verify_page_step_indicator(screen_obj, post_treatment_step): - """ - Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] - @param post_treatment_step : (int) indicates the Current post-treatment step - """ - test.startSection("verification of page step indicators") - for page in range(config.NUM_OF_POST_TREATMENT_BULLETS): - bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj, page))) - bullet_circle_color = bullet_children[0].color.name - #test.log() - bullet_border_color = bullet_children[0].border.color.name - step_title = squish.waitForObjectExists(get_text_object(screen_obj, config.POST_TREATMENT_SCREENS[page])) - #To verify the step indicators of the completed post treatment screens - if page < post_treatment_step: - test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) - test.compare(bullet_circle_color, config.CURRENT_COLOR) - test.compare(bullet_border_color,config.COMPLETE_COLOR) - test.compare(step_title.color.name,config.ENABLED_COLOR) - #To verify the step indicators of the current post treatment screen - elif page == post_treatment_step: - test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) - test.compare(bullet_circle_color,config.CURRENT_COLOR) - test.compare(bullet_border_color,config.COLOR) - test.compare(step_title.color.name,config.ENABLED_COLOR_ONE) - test.verify(step_title.font.bold) - #To verify the step indicators of the remaining post treatment screens - else: - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete,) - test.compare(step_title.color.name,config.COLOR) - test.compare(bullet_circle_color,config.CURRENT_COLOR) - test.compare(bullet_border_color,config.COLOR) - test.endSection() - def get_text_object(screen_obj, txt): """ @@ -139,50 +101,26 @@ return False + def pressure_pop_up_text_obj(text): names.o_pop_up_pressure_text_obj["text"] = text return names.o_pop_up_pressure_text_obj + def pressure_text_obj(text): names.o_pressure_text_obj["text"] = text return names.o_pressure_text_obj + def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M'): date = datetime.now() return str(date.strftime(date_format)) -def enter_keypad_value(entry): - """ - Method to enter user desired - value using keypad - @param entry: (str) User expected value - """ - test.startSection("Entering {}".format(entry)) - for value in entry: - value = pyInt(value) - key_val = squish.waitForObject(keypad_input(value)) - squish.mouseClick(key_val) - utils.waitForGUI(1) - test.endSection() -def erase_entered_value(input_field): - """ - Method to erase the entered value - @param input_field - (obj) object of input field - """ - test.startSection("Erasing value") - input_field= squish.waitForObject(input_field) - entered_value = str(input_field.text) - for value in range(len(entered_value)+1): - utils.waitForGUI(1) - squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) - - test.compare(str(input_field.text), "", "Input field should be empty") - test.endSection() - def vitals_reading_obj(reading): names.o_vitals_reading["text"] = reading return names.o_vitals_reading + def scroll_to_zone(zone=None, screen_object=None, direction = None): """ @@ -214,34 +152,6 @@ raise LookupError("zone object is not in view to the user after trying 100 times") -def pressure_pop_up_text_obj(text): - names.o_pop_up_pressure_text_obj["text"] = text - return names.o_pop_up_pressure_text_obj - -def pressure_text_obj(text): - names.o_pressure_text_obj["text"] = text - return names.o_pressure_text_obj - -def get_current_date_and_time(): - - date_format='%Y/%b/%d - %H:%M' - date = datetime.now() - return str(date.strftime(date_format)) - -def enter_keypad_value(entry): - """ - Method to enter user desired - value using keypad - @param entry: (str) User expected value - """ - test.startSection("Entering {}".format(entry)) - for value in entry: - value = pyInt(value) - key_val = squish.waitForObject(keypad_input(value)) - squish.mouseClick(key_val) - utils.waitForGUI(0.1) - test.endSection() - def erase_entered_value(input_field): """ Method to erase the entered value @@ -257,65 +167,21 @@ test.compare(str(input_field.text), "", "Input field should be empty") test.endSection() -def vitals_reading_obj(reading): - names.o_vitals_reading["text"] = reading - return names.o_vitals_reading -def keypad_input(key_value): - names.o_keypad_input["text"] = key_value - return names.o_keypad_input - def get_alarm_id_obj(id): names.o_alarm_id["text"] = id return names.o_alarm_id + def get_alarm_msg_obj(msg): names.o_alarm_message["text"] = msg return names.o_alarm_message + def rejection_msg(text): names.o_rejection_msg["text"] = text return names.o_rejection_msg - -def verify_page_step_indicator(screen_obj, pre_treatment_step): - """ - Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] - @param pre_treatment_step : indicates the Current pre-treatment step - """ - test.startSection("verification of page step indicators") - for page in range(len(config.PRE_TREATMENT_SCREENS)): - bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj, page))) - bullet_circle_color = bullet_children[0].color.name - bullet_border_color = bullet_children[0].border.color.name - step_title = squish.waitForObjectExists(get_text_object(screen_obj, config.PRE_TREATMENT_SCREENS[page])) - - if page < pre_treatment_step: - test.log("To verify the step indicator of the completed pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) - test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) - test.compare(bullet_circle_color, config.COMPLETE_COLOR, " the bullet color must be " + str(config.COMPLETE_COLOR)) - test.compare(bullet_border_color, config.COMPLETE_COLOR," the bullet border color must be " + str(config.COMPLETE_COLOR)) - test.compare(step_title.color.name, config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) - - elif page == pre_treatment_step: - test.log("To verify the step indicators of the current pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) - test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) - test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) - test.compare(bullet_border_color,config.COMPLETE_COLOR, " the bullet border color must be " + str(config.COMPLETE_COLOR)) - test.compare(step_title.color.name,config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) - test.verify(step_title.font.bold, " the current text must be in bold") - - else: - test.log("To verify the step indicators of the remaining pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete,) - test.compare(step_title.color.name,config.INCOMPLETE_COLOR, " the text color must be " + str(config.INCOMPLETE_COLOR)) - test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) - test.compare(bullet_border_color,config.INCOMPLETE_COLOR, " the bullet border color must be " + str(config.INCOMPLETE_COLOR)) - test.endSection() - def set_arterial_ranges_min_val(art_low): """ @@ -467,6 +333,7 @@ test.compare(ven_max, ven_high, "Actual Venous range maximum value: {} is equal to Expected value: {}".format(ven_max, ven_high)) test.endSection() + #Methods for create custom treatment def set_venous_ranges_min_val(ven_low): """ @@ -519,6 +386,7 @@ "Actual Venous range minimum value: {} is equal to Expected value: {}".format(ven_min, ven_low)) test.endSection() + def scroll_to_value_on_pop_up(value=None, container=None): """ scroll to the to the value if object is hidden @@ -548,284 +416,7 @@ names.o_heparin_value["text"] = val return names.o_heparin_value -def get_alarm_id_obj(id): - names.o_alarm_id["text"] = id - return names.o_alarm_id - -def get_alarm_msg_obj(msg): - names.o_alarm_message["text"] = msg - return names.o_alarm_message - -def rejection_msg(text): - names.o_rejection_msg["text"] = text - return names.o_rejection_msg -def verify_page_step_indicator(screen_obj, pre_treatment_step): - """ - Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] - @param pre_treatment_step : indicates the Current pre-treatment step - """ - test.startSection("verification of page step indicators") - for page in range(config.NUM_OF_PRETREATMENT_BULLETS): - bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj, page))) - bullet_circle_color = bullet_children[0].color.name - bullet_border_color = bullet_children[0].border.color.name - step_title = squish.waitForObjectExists(get_text_object(screen_obj, config.PRE_TREATMENT_SCREENS[page])) - - if page < pre_treatment_step: - test.log("To verify the step indicator of the completed pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) - test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) - test.compare(bullet_circle_color, config.COMPLETE_COLOR, " the bullet color must be " + str(config.COMPLETE_COLOR)) - test.compare(bullet_border_color, config.COMPLETE_COLOR," the bullet border color must be " + str(config.COMPLETE_COLOR)) - test.compare(step_title.color.name, config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) - - elif page == pre_treatment_step: - test.log("To verify the step indicators of the current pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) - test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) - test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) - test.compare(bullet_border_color,config.COMPLETE_COLOR, " the bullet border color must be " + str(config.COMPLETE_COLOR)) - test.compare(step_title.color.name,config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) - test.verify(step_title.font.bold, " the current text must be in bold") - - else: - test.log("To verify the step indicators of the remaining pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) - test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete,) - test.compare(step_title.color.name,config.INCOMPLETE_COLOR, " the text color must be " + str(config.INCOMPLETE_COLOR)) - test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) - test.compare(bullet_border_color,config.INCOMPLETE_COLOR, " the bullet border color must be " + str(config.INCOMPLETE_COLOR)) - test.endSection() - - -def set_arterial_ranges_min_val(art_low): - """ - Method to set the Arterial range maximum value to user expected value - @param art_low - (int) user expected value - """ - test.startSection("Set Arterial range minimum value to {}".format(art_low)) - arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_min = pyInt(arterial_min.minimum) - arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_max = pyInt(arterial_max.maximum) - low_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) - low_handler_children = object.children(low_handler_parent) - low_handler = low_handler_children[-2] - width = pyInt(low_handler.width) - 8 - height = pyInt(low_handler.height)- 10 - if arterial_min == art_low: - test.passes("Arterial range minimum is already set to {}".format(art_low)) - elif arterial_min < art_low: - while arterial_min != art_low: - squish.mouseDrag(low_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_min += 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - break - else: - continue - elif arterial_min > art_low: - while arterial_min != art_low: - squish.mouseDrag(low_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_min -= 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - break - else: - continue - # arterial blood pressure low limit should be lower than the high limit by atleast 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(low_handler_parent.minValue, arterial_min, "Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - else: - test.compare(arterial_min, art_low, "Actual Arterial range minimum value: {} is equal to Expected value: {}".format(arterial_min, art_low)) - test.endSection() - - -def set_arterial_ranges_max_val(art_high): - """ - Method to set the Arterial range maximum value to user expected value - @param art_high - (int) user expected value - """ - test.startSection("Set Arterial range maximum value to {}".format(art_high)) - arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_max = pyInt(arterial_max.maximum) - arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_min = pyInt(arterial_min.minimum) - high_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) - high_handler_children = object.children(high_handler_parent) - high_handler = high_handler_children[-1] - width = pyInt(high_handler.width) - 20 - height = pyInt(high_handler.height) - 25 - if arterial_max == art_high: - test.passes("Arterial range maximum is already set to {}".format(art_high)) - elif arterial_max < art_high: - while arterial_max != art_high: - squish.mouseDrag(high_handler, -1, height, width, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_max += 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - break - else: - continue - elif arterial_max > art_high: - while arterial_max != art_high: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_max -= 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - break - else: - continue - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(high_handler_parent.maxValue, arterial_max, - "Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - else: - test.compare(arterial_max, art_high, - "Actual Arterial range maximum value: {} is equal to Expected value: {}".format(arterial_max, art_high)) - test.endSection() - - -def set_venous_ranges_max_val(ven_high): - """ - Method to set the Venous range maximum value to user expected value - @param ven_high - (int) user expected value - """ - test.startSection("Set Venous range maximum value to {}".format(ven_high)) - ven_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_max = pyInt(ven_max.maximum) - ven_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_min = pyInt(ven_min.minimum) - high_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous)) - high_handler_children = object.children(high_handler_parent) - high_handler = high_handler_children[-1] - width = pyInt(high_handler.width) - 15 - height = pyInt(high_handler.height) - 10 - if ven_max == ven_high: - test.passes("Venous range maximum is already set to {}".format(ven_high)) - elif ven_max < ven_high: - while ven_max != ven_high: - squish.mouseDrag(high_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_max += 10 - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) - break - else: - continue - elif ven_max > ven_high: - while ven_max != ven_high: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_max -= 10 - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) - break - else: - continue - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(high_handler_parent.maxValue, ven_max, "Venous range maximum value cannot be moved beyond {}".format(ven_max)) - else: - test.compare(ven_max, ven_high, "Actual Venous range maximum value: {} is equal to Expected value: {}".format(ven_max, ven_high)) - test.endSection() - -#Methods for create custom treatment -def set_venous_ranges_min_val(ven_low): - """ - Method to set the Venous range maximum value to user expected value - @param ven_low - (int) user expected value - """ - test.startSection("set Venous range minimum value to {}".format(ven_low)) - ven_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_min = pyInt(ven_min.minimum) - ven_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_max = pyInt(ven_max.maximum) - low_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous)) - low_handler_children = object.children(low_handler_parent) - low_handler = low_handler_children[-2] - width = pyInt(low_handler.width) - 15 - height = pyInt(low_handler.height) - 10 - if ven_min == ven_low: - test.passes("Venous range minimum is already set to {}".format(ven_low)) - elif ven_min < ven_low: - while ven_min != ven_low: - squish.mouseDrag(low_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_min += 10 - if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - squish.mouseDrag(low_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) - break - else: - continue - elif ven_min > ven_low: - while ven_min != ven_low: - squish.mouseDrag(low_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_min -= 10 - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) - break - else: - continue - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(low_handler_parent.minValue, ven_min, - "Venous range minimum value cannot be moved beyond {}".format(ven_min)) - else: - test.compare(ven_min, ven_low, - "Actual Venous range minimum value: {} is equal to Expected value: {}".format(ven_min, ven_low)) - test.endSection() - -def scroll_to_value_on_pop_up(value=None, container=None): - """ - scroll to the to the value if object is hidden - @param value - (obj) value object - @param container - (obj) Container of the value - @return boolean true and false - """ - counter = 0 - while counter <= 100: - try: - counter += 1 - squish.findObject(value) - squish.snooze(0.5) - if check_if_object_is_within_the_container(obj=value, container=container): - return True - else: - raise RuntimeError - except RuntimeError: - ScreenObj = squish.waitForObject(container) - screenHeight = pyInt(ScreenObj.height) - screenWidth = pyInt(ScreenObj.width) - squish.mouseWheel(ScreenObj, screenWidth//2, screenHeight//2, 0, -50, squish.Qt.NoModifier) - raise LookupError("value object is not in view to the user after trying 100 times") - def msg(string): """ Added ### at the right side of the string to make sure that it is a message. @@ -835,6 +426,7 @@ padded_str = "###"+string return padded_str + def navigate_to_pretreatment_screen(mode): """ Method to navigate to sub mode under pre-treatment screen @@ -846,13 +438,11 @@ installation_state=0, dry_self_test_state=0, prime_state=0, recirculate_state=0, patient_connection_state=0) + def self_test_dry_check_list_text(text): names.o_self_test_dry_check_list_text["text"] = text return names.o_self_test_dry_check_list_text -def convert_seconds_into_min_and_sec(seconds): - min_and_sec = time.strftime("%M:%S", time.gmtime(seconds)) - return min_and_sec def get_time(screen_title): """ @@ -876,6 +466,7 @@ time_text = progress_circle_children[1] return time_text.time + def verify_countdown(screen_title, time_out, hd_simulator, dg_simulator): """ Method to verify the count down @@ -900,6 +491,7 @@ 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, screen_title, time_out) test.endSection() + def verify_the_progress(count_down, screen_title, time_out): """ @@ -955,6 +547,7 @@ test.compare(bullet_circle_color, config.CURRENT_COLOR) test.compare(bullet_border_color, config.INCOMPLETE_COLOR) test.endSection() + def verify_missing_object(object_to_check): """ @@ -969,117 +562,8 @@ test.passes("object is not present as expected") squish.testSettings.objectNotFoundDebugging = True - -def set_arterial_ranges_min_val(art_low): - """ - Method to set the Arterial range maximum value to user expected value - @param art_low - (int) user expected value - """ - test.startSection("Set Arterial range minimum value to {}".format(art_low)) - arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_min = pyInt(arterial_min.minimum) - arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_max = pyInt(arterial_max.maximum) - low_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) - low_handler_children = object.children(low_handler_parent) - low_handler = low_handler_children[-2] - width = pyInt(low_handler.width) - 8 - height = pyInt(low_handler.height)- 10 - if arterial_min == art_low: - test.passes("Arterial range minimum is already set to {}".format(art_low)) - elif arterial_min < art_low: - while arterial_min != art_low: - squish.mouseDrag(low_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_min += 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - break - else: - continue - elif arterial_min > art_low: - while arterial_min != art_low: - squish.mouseDrag(low_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_min -= 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - break - else: - continue - # arterial blood pressure low limit should be lower than the high limit by atleast 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(low_handler_parent.minValue, arterial_min, "Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - else: - test.compare(arterial_min, art_low, "Actual Arterial range minimum value: {} is equal to Expected value: {}".format(arterial_min, art_low)) - test.endSection() -def set_arterial_ranges_max_val(art_high): - """ - Method to set the Arterial range maximum value to user expected value - @param art_high - (int) user expected value - """ - test.startSection("Set Arterial range maximum value to {}".format(art_high)) - arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_max = pyInt(arterial_max.maximum) - arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_min = pyInt(arterial_min.minimum) - high_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) - high_handler_children = object.children(high_handler_parent) - high_handler = high_handler_children[-1] - width = pyInt(high_handler.width) - 20 - height = pyInt(high_handler.height) - 25 - if arterial_max == art_high: - test.passes("Arterial range maximum is already set to {}".format(art_high)) - elif arterial_max < art_high: - while arterial_max != art_high: - squish.mouseDrag(high_handler, -1, height, width, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_max += 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - break - else: - continue - elif arterial_max > art_high: - while arterial_max != art_high: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_max -= 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - break - else: - continue - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(high_handler_parent.maxValue, arterial_max, - "Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - else: - test.compare(arterial_max, art_high, - "Actual Arterial range maximum value: {} is equal to Expected value: {}".format(arterial_max, art_high)) - test.endSection() - -def get_text_object(screen_obj, txt): - """ - To obtain a text object based on text provided - @param screen_obj: provides the container on which the txt must be present - @returns a real name object - """ - names.o_text_object["container"] = screen_obj - names.o_text_object["text"] = txt - return names.o_text_object - def verify_color_of_entry(entry, vital_parameter, input_field): """ Method to verify the color of entry @@ -1108,16 +592,6 @@ test.compare(input_field_color, config.IN_RANGE_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) test.endSection() -def get_bullet_object(screen_obj, num): - """ - To obtain a bullet object based on occurrence provided. - @param screen_obj: provides the container on which the bullet must be present - @param num: provides the occurrence value - @returns a real name object - """ - names.o_bullet_object["container"] = screen_obj - names.o_bullet_object["occurrence"] = num + 1 - return names.o_bullet_object def keypad_input(key_value): """ @@ -1130,6 +604,7 @@ else: test.log("Invalid text for object.") names.o_keypad_input["text"] = None + def enter_keypad_value(entry): """ @@ -1142,67 +617,8 @@ for value in entry: squish.mouseClick(squish.waitForObject(keypad_input(value))) test.endSection() - - -def erase_entered_value(input_field): - """ - Method to erase the entered value - @param input_field - (obj) object of input field - """ - test.startSection("Erasing value") - input_field= squish.waitForObject(input_field) - entered_value = str(input_field.text) - for value in range(len(entered_value)+1): - utils.waitForGUI(1) - squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) - - test.compare(str(input_field.text), "", "Input field should be empty") - test.endSection() - -def get_indicators(screen_obj, txt): - """ - Verifying the busy indicators for BiCarb Pump Check and Acid Pump Check. - indicator object of expected text - @param step - (str) expected text - @return indicators - (obj) list of busy and check indicator - """ - parent_obj = object.parent(squish.waitForObjectExists(get_text_object(screen_obj,txt))) - children_obj = object.children(parent_obj) - indicator_parent = children_obj[2] - indicators = object.children(indicator_parent) - return indicators -def convert_seconds_into_min_and_sec(seconds, format="%M:%S"): - min_and_sec = time.strftime(format, time.gmtime(seconds)) - return min_and_sec -def expected_heparin_value(val): - names.o_heparin_value["text"] = val - return names.o_heparin_value - -def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): - - date = datetime.now() - return str(date.strftime(date_format)) - -def navigate_to_pretreatment_screen(mode): - """ - Method to navigate to sub mode under pre-treatment screen - @param mode - (int) pre treatment state - """ - hd_simulator.cmd_set_hd_operation_mode_data(5,0) - - hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=mode, 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=0, patient_connection_state=0) - - - -def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): - - date = datetime.now() - return str(date.strftime(date_format)) - def is_float(num): """ This function checks the value is adaptable for float conversion. @@ -1249,7 +665,8 @@ return latest_file except: return False - + + def get_message_from_log(file_name, message_text): """ @@ -1293,6 +710,7 @@ test.fail("application log data is corrupted") except: test.fail("Log file is not created or log file is not created based on standard log naming format.") + def get_ack_request_details(file_name, message_text): """ @@ -1336,7 +754,6 @@ test.fail("Log file is not created or log file is not created based on standard log naming format.") - def get_bak_request_details(file_name, ack_bak_value): """ This method intended to extract the acknowledgement back status from application log. @@ -1366,6 +783,7 @@ test.fail("application log data is corrupted") except: test.fail("Log file is not created or log file is not created based on standard log naming format.") + def get_current_log_details(message_ack = False, message_text = None): """ @@ -1393,283 +811,29 @@ content_record.append(ack_bak_status) return content_record + def vitals_interval_obj(interval): names.o_time_interval_obj["text"] = interval return names.o_time_interval_obj -def msg(string): - """ - Added ### at the right side of the string to make sure that it is a message. - @param string: (str) the string to add trailing ### to - @return pad_str: (str) padded string - """ - padded_str = "###"+string - return padded_str -def set_arterial_ranges_min_val(art_low): - """ - Method to set the Arterial range maximum value to user expected value - @param art_low - (int) user expected value - """ - test.startSection("Set Arterial range minimum value to {}".format(art_low)) - arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_min = pyInt(arterial_min.minimum) - arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_max = pyInt(arterial_max.maximum) - low_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) - low_handler_children = object.children(low_handler_parent) - low_handler = low_handler_children[-2] - width = pyInt(low_handler.width) - 8 - height = pyInt(low_handler.height)- 10 - if arterial_min == art_low: - test.passes("Arterial range minimum is already set to {}".format(art_low)) - elif arterial_min < art_low: - while arterial_min != art_low: - squish.mouseDrag(low_handler, width, height, 1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_min += 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - break - else: - continue - elif arterial_min > art_low: - while arterial_min != art_low: - squish.mouseDrag(low_handler, width, height, -1, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_min -= 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - break - else: - continue - # arterial blood pressure low limit should be lower than the high limit by atleast 30mmHg - if arterial_min == arterial_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(low_handler_parent.minValue, arterial_min, "Arterial range minimum value cannot be moved beyond {}".format(arterial_min)) - else: - test.compare(arterial_min, art_low, "Actual Arterial range minimum value: {} is equal to Expected value: {}".format(arterial_min, art_low)) - test.endSection() +# def cmd_set_create_treatment_click_event(response): +# """ +# Sends a set RTC response message +# +# @param response: (int) 0=NO, 1=YES +# @return: N +# """ +# test.log("HD: Sending response {0}".format(response)) +# +# payload = integer_to_bytearray(response) +# +# message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_hd_ch_id, +# message_id=MsgIds.MSG_ID_UI_INITIATE_TREATMENT_REQUEST.value, +# payload=payload) +# return message - -def set_arterial_ranges_max_val(art_high): - """ - Method to set the Arterial range maximum value to user expected value - @param art_high - (int) user expected value - """ - test.startSection("Set Arterial range maximum value to {}".format(art_high)) - arterial_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_max = pyInt(arterial_max.maximum) - arterial_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery) - arterial_min = pyInt(arterial_min.minimum) - high_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Artery)) - high_handler_children = object.children(high_handler_parent) - high_handler = high_handler_children[-1] - width = pyInt(high_handler.width) - 20 - height = pyInt(high_handler.height) - 25 - if arterial_max == art_high: - test.passes("Arterial range maximum is already set to {}".format(art_high)) - elif arterial_max < art_high: - while arterial_max != art_high: - squish.mouseDrag(high_handler, -1, height, width, 0, squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_max += 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - break - else: - continue - elif arterial_max > art_high: - while arterial_max != art_high: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - arterial_max -= 10 - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - break - else: - continue - # arterial blood pressure low limit should be lower than the high limit by at least 30mmHg - if arterial_max == arterial_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(high_handler_parent.maxValue, arterial_max, - "Arterial range maximum value cannot be moved beyond {}".format(arterial_max)) - else: - test.compare(arterial_max, art_high, - "Actual Arterial range maximum value: {} is equal to Expected value: {}".format(arterial_max, art_high)) - test.endSection() -def set_venous_ranges_max_val(ven_high): - """ - Method to set the Venous range maximum value to user expected value - @param ven_high - (int) user expected value - """ - test.startSection("Set Venous range maximum value to {}".format(ven_high)) - ven_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_max = pyInt(ven_max.maximum) - ven_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_min = pyInt(ven_min.minimum) - high_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous)) - high_handler_children = object.children(high_handler_parent) - high_handler = high_handler_children[-1] - width = pyInt(high_handler.width) - 15 - height = pyInt(high_handler.height) - 10 - if ven_max == ven_high: - test.passes("Venous range maximum is already set to {}".format(ven_high)) - elif ven_max < ven_high: - while ven_max != ven_high: - squish.mouseDrag(high_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_max += 10 - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) - break - else: - continue - elif ven_max > ven_high: - while ven_max != ven_high: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_max -= 10 - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(high_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range maximum value cannot be moved beyond {}".format(ven_max)) - break - else: - continue - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_max == ven_min + config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(high_handler_parent.maxValue, ven_max, "Venous range maximum value cannot be moved beyond {}".format(ven_max)) - else: - test.compare(ven_max, ven_high, "Actual Venous range maximum value: {} is equal to Expected value: {}".format(ven_max, ven_high)) - test.endSection() - -#Methods for create custom treatment -def set_venous_ranges_min_val(ven_low): - """ - Method to set the Venous range maximum value to user expected value - @param ven_low - (int) user expected value - """ - test.startSection("set Venous range minimum value to {}".format(ven_low)) - ven_min = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_min = pyInt(ven_min.minimum) - ven_max = squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous) - ven_max = pyInt(ven_max.maximum) - low_handler_parent = object.parent(squish.waitForObjectExists(names.o_PreTreatmentCreate_rangeRect_RangeRect_Venous)) - low_handler_children = object.children(low_handler_parent) - low_handler = low_handler_children[-2] - width = pyInt(low_handler.width) - 15 - height = pyInt(low_handler.height) - 10 - if ven_min == ven_low: - test.passes("Venous range minimum is already set to {}".format(ven_low)) - elif ven_min < ven_low: - while ven_min != ven_low: - squish.mouseDrag(low_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_min += 10 - if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - squish.mouseDrag(low_handler, width, height, 1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) - break - else: - continue - elif ven_min > ven_low: - while ven_min != ven_low: - squish.mouseDrag(low_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - ven_min -= 10 - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - squish.mouseDrag(low_handler, width, height, -1, 0, - squish.Qt.NoModifier, squish.Qt.LeftButton) - test.log("Venous range minimum value cannot be moved beyond {}".format(ven_min)) - break - else: - continue - # venous blood pressure low limit should be lower than the high limit by at least 30mmHg - if ven_min == ven_max - config.BUFFER_LOW_AND_HIGH_LIMITS: - test.compare(low_handler_parent.minValue, ven_min, - "Venous range minimum value cannot be moved beyond {}".format(ven_min)) - else: - test.compare(ven_min, ven_low, - "Actual Venous range minimum value: {} is equal to Expected value: {}".format(ven_min, ven_low)) - test.endSection() - -def enter_keypad_value_bphr(entry): - """ - Method to enter user desired - value using keypad - @param entry: (str) User expected value - """ - test.startSection("Entering {}".format(entry)) - entry = pyStr(entry) #type casted into string format - for value in entry: - squish.mouseClick(squish.waitForObject(keypad_input(value))) - test.endSection() - - -def ui_all_publication_handler(message: dict) -> None: - """ - This function is the default handler of the ui received messages which only prints out the received message - - This function can be used as an example. - - Be careful that there is only one ui publication method - and it will be overwritten on each call to the function set_ui_all_publication of the HDSimulator. - Look into the _init_loader of the Simulator class for example on how to register. - self.interface.hd.set_ui_all_publication(ui_all_publication_handler) - - This function is filtering the two message ID: - MsgIds.MSG_ID_UI_CHECK_IN.value, - MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value - for the simplicity of the printed message and as example of how to filter. - That filter can obviously be removed. - - @param message: the ui received message - @return: event binary from simulator - """ - exception_msg_id = { - MsgIds.MSG_ID_UI_CHECK_IN.value, - MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value - } - msg_id = DenaliMessage.get_message_id(message) - if msg_id in exception_msg_id: - return - - message_list = DenaliCanMessenger.convert_message_to_string(message) - event_binary = "" + pad_message_with_zeros(message_list) - - return event_binary - - -def cmd_set_create_treatment_click_event(response): - """ - Sends a set RTC response message - - @param response: (int) 0=NO, 1=YES - @return: N - """ - test.log("HD: Sending response {0}".format(response)) - - payload = integer_to_bytearray(response) - - message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_hd_ch_id, - message_id=MsgIds.MSG_ID_UI_INITIATE_TREATMENT_REQUEST.value, - payload=payload) - - return message - - def get_extracted_error_file(): """ This function is the handler for getting error file from service folder. @@ -1685,51 +849,12 @@ except: return False -def scroll_to_value_on_pop_up(value=None, container=None): - """ - scroll to the to the value if object is hidden - @param value - (obj) value object - @param container - (obj) Container of the value - @return boolean true and false - """ - counter = 0 - while counter <= 100: - try: - counter += 1 - squish.findObject(value) - squish.snooze(0.5) - if check_if_object_is_within_the_container(obj=value, container=container): - return True - else: - raise RuntimeError - except RuntimeError: - ScreenObj = squish.waitForObject(container) - screenHeight = pyInt(ScreenObj.height) - screenWidth = pyInt(ScreenObj.width) - squish.mouseWheel(ScreenObj, screenWidth//2, - screenHeight//2, 0, -50, squish.Qt.NoModifier) - - raise LookupError("value object is not in view to the user after " + \ - "trying 100 times") -def expected_heparin_value(val): - names.o_heparin_value["text"] = val - return names.o_heparin_value - - -def msg(string): - """ - Added ### at the right side of the string to make sure that it is a message. - @param string: (str) the string to add trailing ### to - @return pad_str: (str) padded string - """ - padded_str = "###"+string - return padded_str - def keyboard_input(key_value): names.o_keyboard_object["text"] = key_value return names.o_keyboard_object + def enter_keyboard_numeric_value(entry): """ Method to enter user desired @@ -1746,108 +871,8 @@ squish.mouseClick(key_val) utils.waitForGUI(0.1) test.endSection() - -def keypad_input(key_value): - names.o_keypad_input["text"] = key_value - return names.o_keypad_input - -def enter_keypad_value(entry): - """ - Method to enter user desired - value using keypad - @param entry: (str) User expected value - """ - test.startSection("Entering {}".format(entry)) - entry = pyStr(entry) - for value in entry: - value = pyInt(value) - key_val = squish.waitForObject(keypad_input(value)) - squish.mouseClick(key_val) - utils.waitForGUI(0.1) - test.endSection() - - -def erase_entered_value(input_field): - """ - Method to erase the entered value - @param input_field - (obj) object of input field - """ - test.startSection("Erasing value") - input_field= squish.waitForObject(input_field) - entered_value = str(input_field.text) - for value in range(len(entered_value)+1): - utils.waitForGUI(0.1) - squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) - - test.compare(str(input_field.text), "", "Input field should be empty") - test.endSection() - -def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): - date = datetime.now() - return str(date.strftime(date_format)) -def is_float(num): - """ - This function checks the value is adaptable for float conversion. - - @param num - (string) input value for conversion. - @return True/False- (bool) returns True if the value can type casted into float, else False - """ - try: - if '.' in num: - float(num) - return True - except ValueError: - return False - - -def is_intiger(num): - """ - This function checks the value is adaptable for integer conversion. - - @param num - (string) (string) input value for conversion. - @return True/False- (bool) returns True if the value can type casted into int, else False - """ - try: - if num.isdigit(): - return True - except ValueError: - return False - -def scroll_to_zone(zone=None, screen_object=None, direction = None): - """ - scroll to the UI, if object is hidden - @param zone - object to be find out. - @param screen_object - object of the screen. - @return boolean - """ - counter = 0 - while counter <= 100: - try: - counter += 1 - squish.snooze(0.5) - squish.findObject(zone) - squish.snooze(0.5) - if check_if_object_is_within_the_container(obj=zone, container=screen_object): - return True - else: - raise RuntimeError - except RuntimeError: - ScreenObj = squish.findObject(screen_object) - screenHeight = pyInt(ScreenObj.height) - screenWidth = pyInt(ScreenObj.width) - if direction is None: - squish.mouseWheel(ScreenObj, (screenWidth-100), - 107, 0, -(screenHeight-460), squish.Qt.NoModifier) - else: - squish.mouseWheel(ScreenObj, (screenWidth-100), - -(screenHeight-700), 0, 50, squish.Qt.NoModifier) - - raise LookupError("zone object is not in view to the user after " + \ - "trying 100 times") - - def convert_seconds_into_min_and_sec(seconds, time_format="%M:%S"): """ Method to convert seconds into minute format. @@ -1901,254 +926,56 @@ except: test.fail("log file is not created during application interaction") return False - -def get_extracted_file(): - """ - This function is the handler for getting file from log folder. - - This handler will go inside log folder and looks for newly added log based on current time. - if it satisfied that condition, it will return the exact path of newly created log. - - Application log file is automatically created on '/home/denali/Desktop/sd-card/log/ {current_date}_denaliSquish.log' - - @return latest_file - (string) returns latest file that append on log folder from sd-data - """ - current_date = get_current_date_and_time(date_format = "%Y_%m_%d") - latest_file = '/home/denali/Desktop/sd-card/log/'+current_date+'_denaliSquish.log' - return latest_file - - -def get_message_from_log(file_name, message_text): - - """ - This method intended to extract the message from application log. - For row[index], index represent column to be extracted. - - @param file_name - (string) path of the latest log file created. - @param message_text - (string) message text to be extracted. - @return message - (list) API arguments displayed in log. - """ - message = [] - count = 0 - try: - with open(file_name, 'r') as csv_file: - try: - for row in reversed(list(csv.reader(csv_file))): - if row[0].isalpha(): - pass - else: - row_length = sum(1 for values in row) - if row_length >= 4: - if row[3]!= None and row[3] == message_text: - if count == 30: - test.log("2") - test.fail("handler unable to find message text from log file.") - message_length = sum(1 for values in row) - for column in range(4, message_length, 1): - message.append(row[column]) - count +=1 - for value in range(len(message)): - float_status = is_float(message[value]) - int_status = is_intiger(message[value]) - if float_status is True: - message[value] = float(message[value]) - if int_status is True: - message[value] = int(message[value]) - return message - else: - pass - except: - test.fail("application log data is corrupted") - except: - test.fail("Log file is not created or log file is not created based on standard log naming format.") - - -def get_ack_request_details(file_name, message_text): - """ - This method intended to extract acknowledgement request status, negative requested acknowledgement - and message id from application log. - - For row[index], were index represent column to be extracted. - - @param file_name - (string) path of the latest log file created. - @param message_text - (string) message text to be extracted from log. - @return row[3] - (string) acknowledgement request status. - @return row[4] - (string) Negative requested acknowledgement value (Sq). - @return message_id - (string) formatted message id from log. - """ - try: - message_id = " ID" - with open(file_name, 'r') as csv_file: - try: - for row in reversed(list(csv.reader(csv_file))): - if row[0].isalpha(): - pass - else: - row_length = sum(1 for values in row) - if row_length == 6 and row[3] != message_text: - if row[5].split(':')[0] == message_id: - extracted_message_id = pyInt(row[5].split(':')[1], 16) - formatted_message_id = format(extracted_message_id, '#0x') - # MSG_ID_HD_DEBUG_EVENT (0xFFF1) and MSG_ID_DG_DEBUG_EVENT (0xFFF2) hex values are reversed in log. - string_format_id = str(formatted_message_id) - first_two_char = string_format_id[2:4] - last_two_char = string_format_id[-2:] - if last_two_char != '00': - return row[3], row[4], ('0x'+last_two_char+first_two_char) - else: - return row[3], row[4], formatted_message_id.replace("00", "") - else: - pass - except: - test.fail("application log data is corrupted - unable to fetch data") - except: - test.fail("Log file is not created or log file is not created based on standard log naming format.") - - -def get_bak_request_details(file_name, ack_bak_value): - """ - This method intended to extract the acknowledgement back status from application log. - - For row[index], were index represent column to be extracted. - - @param file_name - (string) path of the latest log file created. - @param ack_bak_value - (string) Positive back acknowledgement value (Sq). - @return row[3] - (string) acknowledgement back status. - """ - try: - with open(file_name, 'r') as csv_file: - try: - for row in reversed(list(csv.reader(csv_file))): - if row[0].isalpha(): - pass - else: - row_length = sum(1 for values in row) - if row_length >= 5: - if row[4] == ack_bak_value: - return row[3] - else: - pass - else: - pass - except: - test.fail("application log data is corrupted") - except: - test.fail("Log file is not created or log file is not created based on standard log naming format.") - - - -def get_current_log_details(message_ack = False, message_text = None): - """ - This function is capable to perform data analysis from application log folder. - - logs are automatically created in path :"/home/denali/Desktop/sd-card/log/*.log". - - In row[index], index represent column to be extracted. - @param message_ack - (bool) 'True' - if ack is satisfied in log / 'False' - if ack condition is not satisfied - @param message_text - (string) message text to be extracted from log. - @return content_record - (list) list contains extracted data (ack_req, ack_bak, message, message_id). - """ - content_record = [] - file_name = get_extracted_file() - if message_text != None: - message = get_message_from_log(file_name, message_text) - content_record.append(message) - if message_ack != False: - ack_req_status, ack_req_value, message_id = get_ack_request_details(file_name, message_text) - ack_bak_value = ack_req_value.replace(":-", ":") # getting negative requested ack from positive requested ack - content_record.append(ack_req_status) - content_record.append(message_id.lower()) - if message_ack != False and ack_bak_value != None: - ack_bak_status = get_bak_request_details(file_name, ack_bak_value) - content_record.append(ack_bak_status) - return content_record - - -def get_text_object(screen_obj, txt): - """ - To obtain a text object based on text provided - @param screen_obj: provides the container on which the txt must be present - @returns a real name object - """ - names.o_text_object["container"] = screen_obj - names.o_text_object["text"] = txt - return names.o_text_object - - -def get_bullet_object(screen_obj, num): - """ - To obtain a bullet object based on occurrence provided. - @param screen_obj: provides the container on which the bullet must be present - @param num: provides the occurrence value - @returns a real name object - """ - names.o_bullet_object["container"] = screen_obj - names.o_bullet_object["occurrence"] = num + 1 - return names.o_bullet_object - - -def get_indicators(screen_obj, txt): - """ - Verifying the busy indicators for BiCarb Pump Check and Acid Pump Check. - indicator object of expected text - @param step - (str) expected text - @return indicators - (obj) list of busy and check indicator - """ - parent_obj = object.parent(squish.waitForObjectExists(get_text_object(screen_obj,txt))) - children_obj = object.children(parent_obj) - indicator_parent = children_obj[2] - indicators = object.children(indicator_parent) - return indicators - - -def verify_missing_object(object_to_check): - """ - Method to verify the given object is invisible or is not present on the screen - @param object_to_check: the object whose invisibility must be verified - """ - try: - squish.testSettings.objectNotFoundDebugging = False - squish.waitForObject(object_to_check,3000) - test.fail("Given object should not be present initially") - except LookupError as _: - test.passes("object is not present as expected") - - squish.testSettings.objectNotFoundDebugging = True - - + def verify_page_step_indicator_post_treatment(screen_obj, post_treatment_step): """ - Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] - @param post_treatment_step : (int) indicates the Current post-treatment step - + Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] + @param pre_treatment_step : indicates the Current pre-treatment step """ test.startSection("verification of page step indicators") for page in range(len(config.POST_TREATMENT_SCREENS)): bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj, page))) bullet_circle_color = bullet_children[0].color.name bullet_border_color = bullet_children[0].border.color.name - step_title = squish.waitForObjectExists(get_text_object(screen_obj, config.POST_TREATMENT_SCREENS[0])) - #To verify the step indicators of the completed post-treatment screens + step_title = squish.waitForObjectExists(get_text_object(screen_obj, config.POST_TREATMENT_SCREENS[page])) + if page < post_treatment_step: + test.log("To verify the step indicator of the completed post-treatment screen " + config.POST_TREATMENT_SCREENS[page]) test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) - test.compare(bullet_circle_color, config.COMPLETE_COLOR) - test.compare(bullet_border_color,config.COMPLETE_COLOR) - test.compare(step_title.color.name,config.ENABLED_COLOR) - #To verify the step indicators of the current post-treatment screen + test.compare(bullet_circle_color, config.COMPLETE_COLOR, " the bullet color must be " + str(config.COMPLETE_COLOR)) + test.compare(bullet_border_color, config.COMPLETE_COLOR," the bullet border color must be " + str(config.COMPLETE_COLOR)) + test.compare(step_title.color.name, config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) + elif page == post_treatment_step: - test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) + test.log("To verify the step indicators of the current post-treatment screen " + config.POST_TREATMENT_SCREENS[page]) + test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) - test.compare(bullet_circle_color,config.CURRENT_COLOR) - test.compare(bullet_border_color,config.COMPLETE_COLOR) - test.compare(step_title.color.name,config.ENABLED_COLOR) - #To verify the step indicators of the remaining post-treatment screens + test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) + test.compare(bullet_border_color,config.COMPLETE_COLOR, " the bullet border color must be " + str(config.COMPLETE_COLOR)) + test.compare(step_title.color.name,config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) + test.verify(step_title.font.bold, " the current text must be in bold") + else: + test.log("To verify the step indicators of the remaining post-treatment screen " + config.POST_TREATMENT_SCREENS[page]) test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete,) - test.compare(step_title.color.name,config.INCOMPLETE_COLOR_POST_TREATMENT) - test.compare(bullet_circle_color,config.CURRENT_COLOR) - test.compare(bullet_border_color,config.INCOMPLETE_COLOR) + test.compare(step_title.color.name,config.INCOMPLETE_COLOR, " the text color must be " + str(config.INCOMPLETE_COLOR)) + test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) + test.compare(bullet_border_color,config.INCOMPLETE_COLOR, " the bullet border color must be " + str(config.INCOMPLETE_COLOR)) + test.endSection() + + +def enter_keypad_value_bphr(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + entry = pyStr(entry) #type casted into string format + for value in entry: + squish.mouseClick(squish.waitForObject(keypad_input(value))) test.endSection()