Index: tst_main_treatment_vitals/test.py =================================================================== diff -u -r9ef78246744be74035d8521b7ee71dc84a623883 -re3f67a6e78d267bb99596ba1ce439c6fe7d89a25 --- tst_main_treatment_vitals/test.py (.../test.py) (revision 9ef78246744be74035d8521b7ee71dc84a623883) +++ tst_main_treatment_vitals/test.py (.../test.py) (revision e3f67a6e78d267bb99596ba1ce439c6fe7d89a25) @@ -11,7 +11,6 @@ # date 05/31/2022 # author Papiya Mandal -import builtins import names import time @@ -141,34 +140,6 @@ return start_time -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 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 - entry = builtins.int(entry) - if vital_parameter is config.SYSTOLIC_TEXT: - 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.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.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.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 verify_last_read_time(saved_time): """ @@ -202,7 +173,6 @@ test.compare(last_read_time_without_sec, expected_last_read_time_without_sec, "Last read time should be {}".format(expected_last_read_time_without_sec)) test.endSection() - def verify_entered_value_in_main_treatment_screen(value, vital, save): """ Method to verify the user entered value in main-treatment screen @@ -238,39 +208,76 @@ test.endSection() -def verify_ranges_of_vital(vital_parameter): +def verify_ranges_of_vital(vital_parameter, + set_single_systolic_value = False, systolic_value_to_set = 0, systolic_value_set = SYSTOLIC_VALUES, + set_single_diastolic_value = False, diastolic_value_to_set = 0, diastolic_value_set = DIASTOLIC_VALUES, + set_single_hr_value = False, hr_value_to_set = 0, hr_value_set = HEART_RATE_VALUES): """ Method to verify the in range value for Blood Pressure Systolic and diastolic and heart rate @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) + @param set_single_*_value - indicate whether only setting a single value without traversing list of values + @param *_value_to_set - the single value to set if the set_single_*_value is True, ignored otherwise """ test.startSection("Verify the range of {}".format(vital_parameter)) - if vital_parameter is config.SYSTOLIC_TEXT: - systolic = waitForObject(names.o_pop_up_systolic_input_field) + systolic = waitForObject(names.o_pop_up_systolic_input_field) + diastolic = waitForObject(names.o_pop_up_diastolic_input_field) + hr = waitForObject(names.o_pop_up_heart_rate_input_field) + + is_completed = (str(systolic.text) != "") and (str(diastolic.text) != "") + + test.log(str(is_completed)) + + # HANDLE FOR SYSTOLIC FIELD + if set_single_systolic_value: mouseClick(systolic) - for value in SYSTOLIC_VALUES: + utility.enter_keypad_value(str(systolic_value_to_set)) + verify_entered_value_in_pop_up(value=str(systolic_value_to_set), input_field=systolic, vital=config.SYSTOLIC_TEXT) + + if (vital_parameter is config.SYSTOLIC_TEXT) and (set_single_systolic_value is not True): + mouseClick(systolic) + for value in systolic_value_set: utility.enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=systolic, vital=vital_parameter) - verify_color_of_entry(entry=value, vital_parameter=config.SYSTOLIC_TEXT, input_field=systolic) + is_BP_valid = systolic.text.toInt() >= diastolic.text.toInt() + + #DEBUG test.log(("bp is valid {} comparing {} >= {}").format(is_BP_valid,systolic.text.toInt(),diastolic.text.toInt())) + is_completed = is_completed and is_BP_valid + utility.verify_color_of_entry(entry=value, vital_parameter=config.SYSTOLIC_TEXT, input_field=systolic, is_complete= is_completed) utility.erase_entered_value(input_field=systolic) - elif vital_parameter is config.DIASTOLIC_TEXT: - diastolic = waitForObject(names.o_pop_up_diastolic_input_field) + + # HANDLE FOR DIASTOLIC FIELD: + if set_single_diastolic_value: mouseClick(diastolic) - for value in DIASTOLIC_VALUES: + utility.enter_keypad_value(str(diastolic_value_to_set)) + verify_entered_value_in_pop_up(value=str(diastolic_value_to_set), input_field=diastolic, vital=config.DIASTOLIC_TEXT) + + if (vital_parameter is config.DIASTOLIC_TEXT) and (set_single_diastolic_value is not True): + mouseClick(diastolic) + for value in diastolic_value_set: utility.enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=diastolic, vital=vital_parameter) - verify_color_of_entry(entry=value, vital_parameter=config.DIASTOLIC_TEXT, input_field=diastolic) + is_BP_valid = systolic.text.toInt() >= diastolic.text.toInt() + + test.log(("bp is valid {} comparing {} >= {}").format(is_BP_valid,systolic.text.toInt(),diastolic.text.toInt())) + is_completed = is_completed and is_BP_valid + utility.verify_color_of_entry(entry=value, vital_parameter=config.DIASTOLIC_TEXT, input_field=diastolic, is_complete= is_completed) utility.erase_entered_value(diastolic) - utils.waitForGUI(1) - elif vital_parameter is config.HEART_RATE_TITLE: - hr = waitForObject(names.o_pop_up_heart_rate_input_field) + + # HANDLE FOR HR FIELD + if set_single_hr_value: mouseClick(hr) - for value in HEART_RATE_VALUES: + utility.enter_keypad_value(str(hr_value_to_set)) + verify_entered_value_in_pop_up(value=str(hr_value_to_set), input_field=hr, vital=config.HEART_RATE_TITLE) + + if (vital_parameter is config.HEART_RATE_TITLE) and (set_single_hr_value is not True): + mouseClick(hr) + for value in hr_value_set: utility.enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=hr, vital=vital_parameter) - verify_color_of_entry(entry=value, vital_parameter=config.HEART_RATE_TITLE, input_field=hr) + utility.verify_color_of_entry(entry=value, vital_parameter=config.HEART_RATE_TITLE, input_field=hr, is_complete= is_completed) utility.erase_entered_value(hr) test.endSection() @@ -287,41 +294,7 @@ hr = waitForObject(names.o_PreTreatmentBase_input_TextInput_4) mouseClick(hr) utility.erase_entered_value(hr) - -def verify_the_color_of_out_of_range(vital_parameter): - """ - Method to verify the color of out of range values - @param vital_parameter - (str) parameter name (systolic, diastolic, heart rate) - """ - test.startSection("Verify the color out of range values of {}".format(vital_parameter)) - out_range_val_list = INVALID_VALS[vital_parameter] - if vital_parameter is config.SYSTOLIC_TEXT: - systolic = waitForObject(names.o_pop_up_systolic_input_field) - mouseClick(systolic) - for entry in out_range_val_list: - utility.enter_keypad_value(entry=str(entry)) - verify_entered_value_in_pop_up(value=str(entry), input_field=systolic, vital=vital_parameter) - verify_color_of_entry(entry=entry, vital_parameter=config.SYSTOLIC_TEXT, input_field=systolic) - utility.erase_entered_value(input_field=systolic) - elif vital_parameter is config.DIASTOLIC_TEXT: - diastolic = waitForObject(names.o_pop_up_diastolic_input_field) - mouseClick(diastolic) - for entry in out_range_val_list: - utility.enter_keypad_value(str(entry)) - verify_entered_value_in_pop_up(value=str(entry), input_field=diastolic, vital=vital_parameter) - verify_color_of_entry(entry=entry, vital_parameter=config.DIASTOLIC_TEXT, input_field=diastolic) - utility.erase_entered_value(diastolic) - utils.waitForGUI(1) - elif vital_parameter is config.HEART_RATE_TITLE: - hr = waitForObject(names.o_pop_up_heart_rate_input_field) - mouseClick(hr) - for entry in out_range_val_list: - utility.enter_keypad_value(str(entry)) - verify_entered_value_in_pop_up(value=str(entry), input_field=hr, vital=vital_parameter) - verify_color_of_entry(entry=entry, vital_parameter=config.HEART_RATE_TITLE, input_field=hr) - utility.erase_entered_value(hr) - test.endSection() - + def verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val, dia_val, heart_rate, save): """ @@ -343,7 +316,7 @@ utils.waitForGUI(1) utility.enter_keypad_value(str(sys_val)) verify_entered_value_in_pop_up(value=str(sys_val), input_field=systolic, vital=config.SYSTOLIC_TEXT) - verify_color_of_entry(entry=sys_val, vital_parameter=config.SYSTOLIC_TEXT, input_field=systolic) + utility.verify_color_of_entry(entry=sys_val, vital_parameter=config.SYSTOLIC_TEXT, input_field=systolic, is_complete = False) diastolic = waitForObject(names.o_pop_up_diastolic_input_field) mouseClick(diastolic) @@ -352,14 +325,14 @@ utils.waitForGUI(1) utility.enter_keypad_value(str(dia_val)) verify_entered_value_in_pop_up(value=str(dia_val), input_field=diastolic, vital=config.DIASTOLIC_TEXT) - verify_color_of_entry(entry=dia_val, vital_parameter=config.DIASTOLIC_TEXT, input_field=diastolic) + utility.verify_color_of_entry(entry=dia_val, vital_parameter=config.DIASTOLIC_TEXT, input_field=diastolic) utils.waitForGUI(0.5) hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) utility.erase_entered_value(hr) utility.enter_keypad_value(str(heart_rate)) verify_entered_value_in_pop_up(value=str(heart_rate), input_field=hr, vital=config.HEART_RATE_TITLE) - verify_color_of_entry(entry=heart_rate, vital_parameter=config.HEART_RATE_TITLE, input_field=hr) + utility.verify_color_of_entry(entry=heart_rate, vital_parameter=config.HEART_RATE_TITLE, input_field=hr) if save: test.log("Clicking confirm button") @@ -445,7 +418,7 @@ test.startSection("verification of heparin stop time values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinStopTime_SliderCreateTreatment).label, config.HEPARIN_STOP_TIME, "Parameter should be -> "+str(config.HEPARIN_STOP_TIME)) - test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, 10, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME) + test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, 0, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME) test.endSection() @@ -558,7 +531,7 @@ test.verify(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry).enabled, "systolic combo box should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry).text, str(sys_val), "systolic value should be : " + str(sys_val)) - verify_color_of_entry(entry=sys_val, vital_parameter=config.SYSTOLIC_TEXT, input_field=waitForObject(names.o_PreTreatmentBase_input_TextInput_2)) + utility.verify_color_of_entry(entry=sys_val, vital_parameter=config.SYSTOLIC_TEXT, input_field=waitForObject(names.o_PreTreatmentBase_input_TextInput_2)) mouseClick(waitForObject(names.o_PreTreatmentBase_input_TextInput_3)) @@ -567,16 +540,15 @@ test.verify(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureDiastolic_TextEntry).enabled, "diastolic value should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureDiastolic_TextEntry).text, str(dia_val), "diastolic value should be : "+str(dia_val)) - verify_color_of_entry(entry = dia_val, vital_parameter = config.DIASTOLIC_TEXT, input_field = waitForObject(names.o_PreTreatmentBase_input_TextInput_3)) + utility.verify_color_of_entry(entry = dia_val, vital_parameter = config.DIASTOLIC_TEXT, input_field = waitForObject(names.o_PreTreatmentBase_input_TextInput_3), is_complete = True) - mouseClick(waitForObject(names.o_PreTreatmentBase_input_TextInput_4)) utility.erase_entered_value(names.o_PreTreatmentBase_input_TextInput_4) utility.enter_keypad_value(heart_rate) test.verify(waitForObjectExists(names.o_PreTreatmentBase_heartRate_TextEntry).enabled, "diastolic value should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_heartRate_TextEntry).text, str(heart_rate), "diastolic value should be : "+str(dia_val)) - verify_color_of_entry(entry = heart_rate, vital_parameter = config.HEART_RATE_TITLE, input_field = waitForObject(names.o_PreTreatmentBase_input_TextInput_4)) + utility.verify_color_of_entry(entry = heart_rate, vital_parameter = config.HEART_RATE_TITLE, input_field = waitForObject(names.o_PreTreatmentBase_input_TextInput_4)) test.endSection() @@ -754,7 +726,40 @@ test.log("Total elapsed time : {}".format(total_elapsed_time)) test.compare(close_btn.visible, config.VISIBLE, "Dialog close button should be visible after the vitals pop up is opened automatically") test.endSection() + + +def verify_ranges_of_vitals_fields_complete(vSystolic_value_set, vDiastolic_value_set, vHr_value_set): + """ + This is for the cases that the fields are complete and we are changing one single value + """ + # complete the fields with valid values: + verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, + set_single_systolic_value=True, systolic_value_to_set=config.SYSTOLIC_LOWER_LIMIT, + set_single_diastolic_value=True, diastolic_value_to_set=config.DIASTOLIC_LOWER_LIMIT, + set_single_hr_value=True, hr_value_to_set=config.HEART_RATE_LOWER_LIMIT) + verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, systolic_value_set = vSystolic_value_set) # runs the multiple value test + # complete the fields with valid values: + verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, + set_single_systolic_value=True, systolic_value_to_set=config.SYSTOLIC_LOWER_LIMIT, + set_single_diastolic_value=True, diastolic_value_to_set=config.DIASTOLIC_LOWER_LIMIT, + set_single_hr_value=True, hr_value_to_set=config.HEART_RATE_LOWER_LIMIT) + verify_ranges_of_vital(vital_parameter=config.DIASTOLIC_TEXT, diastolic_value_set=vDiastolic_value_set)# runs the multiple value test + + # complete the fields with valid values: + verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, + set_single_systolic_value=True, systolic_value_to_set=config.SYSTOLIC_LOWER_LIMIT, + set_single_diastolic_value=True, diastolic_value_to_set=config.DIASTOLIC_LOWER_LIMIT, + set_single_hr_value=True, hr_value_to_set=config.HEART_RATE_LOWER_LIMIT) + verify_ranges_of_vital(vital_parameter=config.HEART_RATE_TITLE, hr_value_set = vHr_value_set)# runs the multiple value test + + +def verify_ranges_of_vitals_fields_incomplete(vSystolic_value_set, vDiastolic_value_set, vHr_value_set): + verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, systolic_value_set = vSystolic_value_set) + verify_ranges_of_vital(vital_parameter=config.DIASTOLIC_TEXT, diastolic_value_set=vDiastolic_value_set) + verify_ranges_of_vital(vital_parameter=config.HEART_RATE_TITLE, hr_value_set = vHr_value_set) + + def main(): utils.tstStart(__file__) @@ -796,13 +801,25 @@ verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=SYSTOLIC_PRESSSURE_200,dia_val=DIASTOLIC_PRESSSURE_150, heart_rate=HEART_RATE_VAL_60, save=False) utils.waitForGUI(1) open_vitals_pop_up() - verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT) - verify_ranges_of_vital(vital_parameter=config.DIASTOLIC_TEXT) - verify_ranges_of_vital(vital_parameter=config.HEART_RATE_TITLE) - - verify_the_color_of_out_of_range(vital_parameter=config.SYSTOLIC_TEXT) - verify_the_color_of_out_of_range(vital_parameter=config.DIASTOLIC_TEXT) - verify_the_color_of_out_of_range(vital_parameter=config.HEART_RATE_TITLE) + utils.waitForGUI(1) + # verify the field colors for valid values + verify_ranges_of_vitals_fields_complete(vSystolic_value_set = SYSTOLIC_VALUES, + vDiastolic_value_set = DIASTOLIC_VALUES, + vHr_value_set = HEART_RATE_VALUES) + utils.waitForGUI(1) + verify_ranges_of_vitals_fields_incomplete(vSystolic_value_set = SYSTOLIC_VALUES, + vDiastolic_value_set = DIASTOLIC_VALUES, + vHr_value_set = HEART_RATE_VALUES) + utils.waitForGUI(1) + # verify the field colors for invalid values + verify_ranges_of_vitals_fields_complete(vSystolic_value_set = INVALID_VALS["systolic"], + vDiastolic_value_set = INVALID_VALS["diastolic"], + vHr_value_set = INVALID_VALS["Heart Rate"]) + utils.waitForGUI(1) + verify_ranges_of_vitals_fields_incomplete(vSystolic_value_set = INVALID_VALS["systolic"], + vDiastolic_value_set = INVALID_VALS["diastolic"], + vHr_value_set = INVALID_VALS["Heart Rate"]) + utils.waitForGUI(1) verify_interval_for_bpm()