Index: shared/scripts/configuration/utility.py =================================================================== diff -u -rdd182e384d5248240f343cc4855ff292ba5e4ee3 -r6052b7abfc1d50f6c952a4e12a9bc86c2c5f6e04 --- shared/scripts/configuration/utility.py (.../utility.py) (revision dd182e384d5248240f343cc4855ff292ba5e4ee3) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 6052b7abfc1d50f6c952a4e12a9bc86c2c5f6e04) @@ -101,7 +101,6 @@ 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 @@ -156,12 +155,14 @@ test.passes("object is not present as expected") squish.testSettings.objectNotFoundDebugging = True +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)) @@ -200,7 +201,6 @@ raise LookupError("zone object is not in view to the user after trying 100 times") - def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M'): date = datetime.now() @@ -232,6 +232,43 @@ 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 scroll_to_zone(zone=None, screen_object=None, direction = 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(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, 200, squish.Qt.NoModifier) + + raise LookupError("zone object is not in view to the user after trying 100 times") + def get_alarm_id_obj(id): names.o_alarm_id["text"] = id return names.o_alarm_id @@ -369,7 +406,7 @@ 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)) + 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() @@ -466,30 +503,6 @@ 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 expected_heparin_value(val): names.o_heparin_value["text"] = val return names.o_heparin_value @@ -583,8 +596,159 @@ expected_progress = time_out - count_down test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) test.endSection() - +def verify_page_step_indicator(screen_obj, treatment_step, treatment_screens): + """ + Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] + @param treatment_step : (int) indicates the Current treatment step + """ + test.startSection("verification of page step indicators") + for page in range(len(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, treatment_screens[page])) + #To verify the step indicators of the completed treatment screens + if page < treatment_step: + 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 treatment screen + elif page == 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) + test.verify(step_title.font.bold) + #To verify the step indicators of the remaining 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.INCOMPLETE_COLOR) + 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): + """ + 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 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