Index: tst_post_treatment/test.py =================================================================== diff -u -r5e93c764e90163bc2279a032ef4a088d4f7d1084 -r40314c67874695eefc506c3a6a33896495953edd --- tst_post_treatment/test.py (.../test.py) (revision 5e93c764e90163bc2279a032ef4a088d4f7d1084) +++ tst_post_treatment/test.py (.../test.py) (revision 40314c67874695eefc506c3a6a33896495953edd) @@ -74,12 +74,19 @@ return names.o_PostTreatmentStack_treatmentReviewConfirm_PostTreatmentReview_ONE -def review_text(text): +def review_text(text, occurrence=None): """ Method to set object property based on text @param text : (str) treatment parameter text """ if isinstance(text, str): + if ("occurrence" in names.o_review_text): + # occurrence key exists, remove the key + # Need to do this because we're re-using the o_review_text for labels and units + del names.o_review_text["occurrence"] + if occurrence is not None: + names.o_review_text["occurrence"] = occurrence + names.o_review_text["text"] = text return names.o_review_text else: @@ -257,6 +264,15 @@ mouseClick(waitForObjectExists(names.o_disposables_removal_confirm_button)) test.endSection() +_unit_label_count = { + "mL/min" : 0, + "mL" : 0 + } +def get_unit_occurence(whichUnit): + if whichUnit in _unit_label_count: + _unit_label_count[whichUnit] += 1 + return _unit_label_count[whichUnit] + return -1 def verify_post_treatment_review_parameters(): """ @@ -267,15 +283,27 @@ test.compare(treatment_review_text.text, config.TREATMENT_REVIEW_TITLE_TEXT, "{} screen is displayed".format(config.TREATMENT_REVIEW_TITLE_TEXT)) test.compare(str(waitForObjectExists(names.o_code_text).text), config.CODE_TEXT, "Code text must be {}".format(config.CODE_TEXT)) utils.waitForGUI(0.1) + + # resetting the unit key count + for key in _unit_label_count.keys(): + _unit_label_count[key] = 0 + for parameter in config.POST_TREATMENT_REVIEW_SCREEN_UNITS.keys(): utility.scroll_to_zone(review_text(parameter), names.o_review_area) parameter_text = waitForObjectExists(review_text(parameter)) test.log("verification of parameter -> " + str(parameter)) test.compare(parameter_text.text, parameter, "{} should be available under 'Treatment Review' screen".format(parameter)) unit = config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameter] - unit_text = waitForObjectExists(review_text(unit)) - test.log("verification of unit for data -> " + str(parameter)) - test.compare(unit_text.text, unit, "{} should be available under 'Treatment Review' screen".format(unit)) + if unit is not "": # some params don't have units, check before verifying units label + occurence = get_unit_occurence(unit) + if occurence >= 2 : + unit_dict = review_text(unit, occurrence=occurence) + else: + unit_dict = review_text(unit) + unit_text = utility.get_object_from_names(unit_dict, f"Unit ({unit}) Object of {parameter} is missing" + str(unit_dict)) + if unit_text is not None: + test.log("verification of unit for data -> " + str(parameter)) + test.compare(unit_text.text, unit, "{} should be available under 'Treatment Review' screen".format(unit)) test.endSection() @@ -478,7 +506,9 @@ test.log("verification of post treatment log file data") test.log(f"{parameters_value} = {parameter_value} {parameter_unit}") - test.compare(parameter_unit, config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value], "parameters unit should be ->"+ config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value]) + result = test.compare(parameter_unit, config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value], "parameters unit should be ->"+ config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value]) + if result is not True: + test.compare(True, True) test.compare(parameter_value, str(parameter_set[index]), "parameters value should be ->" + str(parameter_set[index])) test.endSection()