Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r08990cb9543b8deb3f05a05e6172029b4732e889 -r5347ee52338d76725d5f4cdca3f8077ef2997ba3 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 08990cb9543b8deb3f05a05e6172029b4732e889) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 5347ee52338d76725d5f4cdca3f8077ef2997ba3) @@ -74,89 +74,61 @@ raise LookupError("zone object is not in view to the user after " + \ "trying 100 times") - -def page_step_indicator_verification(pre_treatment_step, pre_treatment_items_object): - """ - Method to verify the Page Step indicators on top of the screen which indicates the steps passed, current, remained] - @param pre_treatment_step :(int) indicates the Current pre-treatment step - @param pre_treatment_items_object :(dictionary) pre_treatment bullet object - @return N/A - """ - test.startSection("Method to verify the Page Step indicators from patient connection section") - for page in range(1, len(config.PRE_TREATMENT_SCREENS)): - pre_treatment_items_object["occurrence"] = page - bullet_children = object.children(squish.waitForObject(pre_treatment_items_object)) +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 = bullet_children[2] - #To verify the step indicators of the completed pre treatment screens + step_title = squish.waitForObjectExists(get_text_object(screen_obj, config.PRE_TREATMENT_SCREENS[page])) + if page < pre_treatment_step: - test.verify(squish.waitForObjectExists(pre_treatment_items_object).complete, str(config.PRE_TREATMENT_SCREENS[page]+" complete attribute should be True")) - test.verify(not squish.waitForObjectExists(pre_treatment_items_object).current, str(config.PRE_TREATMENT_SCREENS[page]+" current attribute should be false")) - test.compare(bullet_circle_color, config.COMPLETE_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" bullet color hex should be "+str(config.COMPLETE_COLOR))) - test.compare(bullet_border_color, config.COMPLETE_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" bullet border color hex should be "+str(config.COMPLETE_COLOR))) - test.compare(step_title.color.name, config.ENABLED_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" title color hex should be "+str(config.ENABLED_COLOR))) - #To verify the step indicators of the current pre treatment screen + 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.verify(squish.waitForObjectExists(pre_treatment_items_object).current, str(config.PRE_TREATMENT_SCREENS[page]+" complete attribute should be True")) - test.verify(not squish.waitForObjectExists(pre_treatment_items_object).complete, str(config.PRE_TREATMENT_SCREENS[page]+" current attribute should be false")) - test.compare(bullet_circle_color,config.CURRENT_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" bullet color hex should be "+str(config.CURRENT_COLOR))) - test.compare(bullet_border_color,config.COMPLETE_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" bullet border color hex should be "+str(config.COMPLETE_COLOR))) - test.compare(step_title.color.name,config.ENABLED_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" title color hex should be "+str(config.ENABLED_COLOR))) - test.verify(step_title.font.bold, str(config.PRE_TREATMENT_SCREENS[page]+" title font bold should be "+str(config.ENABLED_COLOR))) - #To verify the step indicators of the remaining pre-treatment screens + 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.verify(not squish.waitForObjectExists(pre_treatment_items_object).current, str(config.PRE_TREATMENT_SCREENS[page]+" complete attribute should be false")) - test.verify(not squish.waitForObjectExists(pre_treatment_items_object).complete, str(config.PRE_TREATMENT_SCREENS[page]+" current attribute should be false")) - test.compare(step_title.color.name,config.INCOMPLETE_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" title color hex should be "+str(config.INCOMPLETE_COLOR))) - test.compare(bullet_circle_color,config.CURRENT_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" bullet circle color hex should be "+str(config.CURRENT_COLOR))) - test.compare(bullet_border_color,config.INCOMPLETE_COLOR, str(config.PRE_TREATMENT_SCREENS[page]+" bullet border color hex should be "+str(config.INCOMPLETE_COLOR))) - - test.endSection() + 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 instruction_screen_indicator_verification(current_indicator, training_items_object): +def get_text_object(screen_obj, txt): """ - Method to verify the pre treatment tutorial indicators on top of the screen which indicates the steps passed, current, remained] - @param current_indicator :(int) Current pre-treatment tutorial indicator - @param training_items_object :(dictionary) pre_treatment bullet object - @return N/A - """ - test.startSection("Method to verify the Page Step indicators from training screen") - for page in range(config.TRAINING_INDICATOR_SCREEN): - occurrence_index = 10 + page #1-9 occurrence of object belongs to page indicators, 10 - 13 occurrence of object belongs to training indicators - training_items_object["occurrence"] = occurrence_index - bullet_children = object.children(squish.waitForObject(training_items_object)) - bullet_circle_color = bullet_children[0].color.name - bullet_border_color = bullet_children[0].border.color.name - #To verify the step indicators of pre treatment tutorial screens - if page < current_indicator: - test.verify(squish.waitForObjectExists(training_items_object).complete, "bullet indicator {index} should be in complete state".format(index=current_indicator)) - test.verify(not squish.waitForObjectExists(training_items_object).current, "bullet indicator {index} current attribute should be unchecked".format(index=current_indicator)) - test.compare(bullet_circle_color, config.COMPLETE_COLOR, " bullet color hex should be "+str(config.COMPLETE_COLOR)) - test.compare(bullet_border_color, config.COMPLETE_COLOR, " bullet border color hex should be "+str(config.COMPLETE_COLOR)) - #To verify the step indicators of pre treatment tutorial screen - elif page == current_indicator: - test.verify(squish.waitForObjectExists(training_items_object).current, "bullet indicator {index} should be in complete state".format(index=current_indicator)) - test.verify(not squish.waitForObjectExists(training_items_object).complete, "bullet indicator {index} current attribute should be unchecked".format(index=current_indicator)) - test.compare(bullet_circle_color,config.COMPLETE_COLOR, "bullet color hex should be "+str(config.CURRENT_COLOR)) - test.compare(bullet_border_color,config.COMPLETE_COLOR, "bullet border color hex should be "+str(config.COMPLETE_COLOR)) - #To verify the step indicators of pre-treatment tutorial screens - else: - test.verify(not squish.waitForObjectExists(training_items_object).current, "bullet indicator {index} should not be complete state".format(index=current_indicator)) - test.verify(not squish.waitForObjectExists(training_items_object).complete, "bullet indicator {index} current attribute should be unchecked".format(index=current_indicator)) - test.compare(bullet_circle_color,config.CURRENT_COLOR, "bullet circle color hex should be "+str(config.CURRENT_COLOR)) - test.compare(bullet_border_color,config.INCOMPLETE_COLOR, "bullet border color hex should be "+str(config.INCOMPLETE_COLOR)) - - test.endSection() + 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 = 0, vital_parameter = None, input_field = None): +def verify_color_of_entry(entry, vital_parameter, input_field): """ - Method to verify the color of entry of systolic, diastolic and heart rate - @param entry: (int) user entered value - @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) - @param input_field - (obj) object of input field + Method to verify the color of entry + of systolic, diastolic and heart rate + @param entry: (int) user user entered value + @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) + @param input_field - (obj) object of input field """ test.startSection("Verify the color of {} value {}".format(vital_parameter, entry)) input_field_color = input_field.color.name @@ -165,19 +137,31 @@ if (entry < config.SYSTOLIC_LOWER_LIMIT) or (entry > config.SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) elif (entry >= config.SYSTOLIC_LOWER_LIMIT) and (entry <= config.SYSTOLIC_UPPER_LIMIT): - test.compare(input_field_color, config.ENABLED_COLOR, "systolic value {} is in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) + test.compare(input_field_color, config.IN_RANGE_COLOR, "systolic value {} is in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) elif vital_parameter is config.DIASTOLIC_TEXT: if (entry < config.DIASTOLIC_LOWER_LIMIT) or (entry > config.DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) elif (entry >= config.DIASTOLIC_LOWER_LIMIT) and (entry <= config.DIASTOLIC_UPPER_LIMIT): - test.compare(input_field_color, config.ENABLED_COLOR, "diastolic value {} is in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + test.compare(input_field_color, config.IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) elif vital_parameter is config.HEART_RATE_TITLE: if (entry < config.HEART_RATE_LOWER_LIMIT) or (entry > config.HEART_RATE_UPPER_LIMIT): test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) elif (entry >= config.HEART_RATE_LOWER_LIMIT) and (entry <= config.HEART_RATE_UPPER_LIMIT): - test.compare(input_field_color,config.ENABLED_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) - test.endSection() + 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): """