Index: tst_main_treatment_vitals/test.py =================================================================== diff -u -rb13829a8464f54a4baa6908d569ae1181118d5ac -r62b41ac739f27813608a6b4eb0bdd9ee4331d64f --- tst_main_treatment_vitals/test.py (.../test.py) (revision b13829a8464f54a4baa6908d569ae1181118d5ac) +++ tst_main_treatment_vitals/test.py (.../test.py) (revision 62b41ac739f27813608a6b4eb0bdd9ee4331d64f) @@ -59,103 +59,74 @@ test.compare(bp_title, BLOOD_PRESSURE_TITLE,"Blood pressure title text is displayed") bp_uom = waitForObject(names.o_bp_uom) bp_uom = bp_uom.text.toUtf8().constData() - test.compare(bp_uom, BLOOD_PRESSURE_UNIT,"Blood pressure unit " + - "should be {unit}".format(unit=BLOOD_PRESSURE_UNIT)) + test.compare(bp_uom, BLOOD_PRESSURE_UNIT,"Blood pressure unit should be {}".format(BLOOD_PRESSURE_UNIT)) heart_rate_title = waitForObject(names.o_pop_up_heart_rate_title) heart_rate_title = heart_rate_title.text.toUtf8().constData() test.compare(heart_rate_title, HEART_RATE_TITLE,"Heart rate title text is displayed") hr_uom = waitForObject(names.o_hr_uom) hr_uom = hr_uom.text.toUtf8().constData() - test.compare(hr_uom, HEART_RATE_UNIT,"Heart Rate unit " + - "should be {unit}".format(unit=HEART_RATE_UNIT)) + test.compare(hr_uom, HEART_RATE_UNIT,"Heart Rate unit should be {}".format(HEART_RATE_UNIT)) test.endSection() 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: user user entered value - @param vital_parameter - parameter name under which user - is entering value (sys/dia/heart rate) - @param input_field - object of input field + @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 {vital_parameter} value {entry}".format(\ - vital_parameter=vital_parameter, entry=entry)) + 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 SYSTOLIC_TEXT: if (entry < SYSTOLIC_LOWER_LIMIT) or (entry > SYSTOLIC_UPPER_LIMIT): - test.compare(input_field_color, OUT_OF_RANGE_COLOR, "systolic value " + - "{entry} is out of range, systolic value should be in range of ".format(entry=entry) - + "{lower_limit} and {upper_limit}".format(lower_limit=SYSTOLIC_LOWER_LIMIT, - upper_limit=SYSTOLIC_UPPER_LIMIT)) + test.compare(input_field_color, OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT)) elif (entry >= SYSTOLIC_LOWER_LIMIT) and (entry <= SYSTOLIC_UPPER_LIMIT): - test.compare(input_field_color, IN_RANGE_COLOR, "systolic value {entry}".format(entry=entry) - + " is in range of {lower_limit} and {upper_limit}".format(\ - lower_limit=SYSTOLIC_LOWER_LIMIT, - upper_limit=SYSTOLIC_UPPER_LIMIT)) + test.compare(input_field_color, IN_RANGE_COLOR, "systolic value {} is in range of {} and {}".format(entry, SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT)) elif vital_parameter is DIASTOLIC_TEXT: if (entry < DIASTOLIC_LOWER_LIMIT) or (entry > DIASTOLIC_UPPER_LIMIT): - test.compare(input_field_color, OUT_OF_RANGE_COLOR, "diastolic value " + - "{entry} is out of range, diastolic value should be in range of ".format(entry=entry) - + "{lower_limit} and {upper_limit}".format(lower_limit=DIASTOLIC_LOWER_LIMIT, - upper_limit=DIASTOLIC_UPPER_LIMIT)) + test.compare(input_field_color, OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT)) elif (entry >= DIASTOLIC_LOWER_LIMIT) and (entry <= DIASTOLIC_UPPER_LIMIT): - test.compare(input_field_color,IN_RANGE_COLOR, "diastolic value {entry}".format(entry=entry) - + " is in range of {lower_limit} and {upper_limit}".format(\ - lower_limit=DIASTOLIC_LOWER_LIMIT, - upper_limit=DIASTOLIC_UPPER_LIMIT)) + test.compare(input_field_color, IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT)) elif vital_parameter is HEART_RATE_TITLE: if (entry < HEART_RATE_LOWER_LIMIT) or (entry > HEART_RATE_UPPER_LIMIT): - test.compare(input_field_color, OUT_OF_RANGE_COLOR, "Heart Rate value " + - "{entry} is out of range, Heart Rate value should be in range of ".format(entry=entry) - + "{lower_limit} and {upper_limit}".format(lower_limit=HEART_RATE_LOWER_LIMIT, - upper_limit=HEART_RATE_UPPER_LIMIT)) + test.compare(input_field_color, OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT)) elif (entry >= HEART_RATE_LOWER_LIMIT) and (entry <= HEART_RATE_UPPER_LIMIT): - test.compare(input_field_color,IN_RANGE_COLOR, "Heart Rate value {entry}".format(entry=entry) - + " is in range of {lower_limit} and {upper_limit}".format(\ - lower_limit=HEART_RATE_LOWER_LIMIT, - upper_limit=HEART_RATE_UPPER_LIMIT)) + test.compare(input_field_color,IN_RANGE_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT)) test.endSection() def verify_last_read_time(saved_time): """ - method to verify the last read of blood pressure - and heart rate - @param last_read: time of saving blood pressure and heart rate + method to verify the last read of blood pressure and heart rate + @param last_read: (str) time of saving blood pressure and heart rate """ test.startSection("Verify the last read of blood pressure and heart rate") - expected_last_read = "Interval: 30min , Last Read: {saved_time}".format(saved_time=saved_time) - last_read = waitForObject(names.vitals_reading_obj(reading=expected_last_read)) + expected_last_read = "Interval: 30min , Last Read: {}".format(saved_time) + last_read = waitForObject(names.vitals_reading_obj(expected_last_read)) last_read = last_read.text.toUtf8().constData() - test.compare(last_read, expected_last_read, - "Last read time should be {last_read}".format(last_read=last_read)) + test.compare(last_read, expected_last_read, "Last read time should be {}".format(last_read)) test.endSection() def verify_entered_value_in_main_treatment_screen(value, vital, save): """ - method to verify the user entered value - in main-treatment screen - @param value: user user entered value - @param vital - parameter name under which user - is entering value (sys/dia/heart rate) - @param input_field - object of input field + method to verify the user entered value in main-treatment screen + @param value: (int) user user entered value + @param vital - (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 user entered {vital} ".format(vital=vital) + - "value {value} in main-treatment screen".format(value=value)) + test.startSection("Verify the user entered {} value {} in main-treatment screen".format(vital, value)) if save: - input_field = waitForObject(names.vitals_reading_obj(reading=value)) + input_field = waitForObject(names.vitals_reading_obj(value)) entered_value = input_field.text.toUtf8().constData() value = str(value) test.compare(entered_value, value, - "Expected {vital} value: {value} ".format(vital=vital, value=value) + - "should be equal to Actual {vital} value: ".format(vital=vital) + - "{actual_value}".format(actual_value=entered_value)) + "Expected {} value: {} should be equal to Actual {} value: {}".format(vital, value, vital, entered_value)) elif (save is False): - if object.exists(names.vitals_reading_obj(reading=value)) is False: + if object.exists(names.vitals_reading_obj(value)) is False: test.log("Entered is not saved and is not updated in main-treatment screen") test.endSection() @@ -164,19 +135,15 @@ def verify_entered_value_in_pop_up(value, input_field, vital): """ method to verify the user entered value - @param value: user user entered value - @param value: user user entered value - @param vital - parameter name under which user - is entering value (sys/dia/heart rate) + @param value - (int) user entered value + @param vital - (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 user entered {vital} ".format(vital=vital) + - "value {value}".format(value=value)) + test.startSection("Verify the user entered {} value {}".format(vital, value)) input_field = waitForObject(input_field) entered_value = input_field.text.toUtf8().constData() test.compare(entered_value, value, - "Expected {vital} value: {value} ".format(vital=vital, value=value) + - "should be equal to Actual {vital} value: ".format(vital=vital) + - "{actual_value}".format(actual_value=entered_value)) + "Expected {} value: {} should be equal to Actual {} value: {}".format(vital, value, vital, entered_value)) test.endSection() @@ -185,15 +152,15 @@ Method to verify the in range value for Blood Pressure Systolic and diastolic and heart rate - @param vital_parameter - parameter name under which user + @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) """ - test.startSection("Verify the range of {vital}".format(vital=vital_parameter)) + test.startSection("Verify the range of {}".format(vital_parameter)) if vital_parameter is SYSTOLIC_TEXT: systolic = waitForObject(names.o_pop_up_systolic_input_field) mouseClick(systolic) for value in range(SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT+1): - enter_keypad_value(entry=str(value)) + 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=SYSTOLIC_TEXT, @@ -203,32 +170,31 @@ diastolic = waitForObject(names.o_pop_up_diastolic_input_field) mouseClick(diastolic) for value in range(DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT+1): - enter_keypad_value(entry=str(value)) + 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=DIASTOLIC_TEXT, input_field=diastolic) - erase_entered_value(input_field=diastolic) + erase_entered_value(diastolic) elif vital_parameter is HEART_RATE_TITLE: hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) for value in range(HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT+1): - enter_keypad_value(entry=str(value)) + 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=HEART_RATE_TITLE, input_field=hr) - erase_entered_value(input_field=hr) + erase_entered_value(hr) test.endSection() def verify_the_color_of_out_of_range(vital_parameter): """ Method to verify the color of out of range values - @param vital_parameter : parameter name (systolic, diastolic, heart rate) + @param vital_parameter - (str) parameter name (systolic, diastolic, heart rate) """ - test.startSection("Verify the color out of range values of " + - "{vital}".format(vital=vital_parameter)) + 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 SYSTOLIC_TEXT: systolic = waitForObject(names.o_pop_up_systolic_input_field) @@ -244,22 +210,22 @@ diastolic = waitForObject(names.o_pop_up_diastolic_input_field) mouseClick(diastolic) for entry in out_range_val_list: - enter_keypad_value(entry=str(entry)) + 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=DIASTOLIC_TEXT, input_field=diastolic) - erase_entered_value(input_field=diastolic) + erase_entered_value(diastolic) elif vital_parameter is HEART_RATE_TITLE: hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) for entry in out_range_val_list: - enter_keypad_value(entry=str(entry)) + 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=HEART_RATE_TITLE, input_field=hr) - erase_entered_value(input_field=hr) + erase_entered_value(hr) test.endSection() @@ -269,29 +235,32 @@ heart rate value and save or unsave it and verify same is updated in main-treatment screen + @param sys_val - (int) user expected systolic pressure + @param dia_val - (int) user expected diastolic pressure + @param heart_rate - (int) user expected heart rate + @param save - (bool) True/False """ - test.startSection("Verify the entered systolic, diastolic and heart rate " + - "value updated in main-treatement screen") + test.startSection("Verify the entered systolic, diastolic and heart rate value updated in main-treatement screen") systolic = waitForObject(names.o_pop_up_systolic_input_field) mouseClick(systolic) - erase_entered_value(input_field=systolic) - enter_keypad_value(entry=str(sys_val)) + erase_entered_value(systolic) + enter_keypad_value(str(sys_val)) verify_entered_value_in_pop_up(value=str(sys_val), input_field=systolic, vital=SYSTOLIC_TEXT) verify_color_of_entry(entry=sys_val, vital_parameter=SYSTOLIC_TEXT, input_field=systolic) diastolic = waitForObject(names.o_pop_up_diastolic_input_field) mouseClick(diastolic) - erase_entered_value(input_field=diastolic) - enter_keypad_value(entry=str(dia_val)) + erase_entered_value(diastolic) + enter_keypad_value(str(dia_val)) verify_entered_value_in_pop_up(value=str(dia_val), input_field=diastolic, vital=DIASTOLIC_TEXT) verify_color_of_entry(entry=dia_val, vital_parameter=DIASTOLIC_TEXT, input_field=diastolic) hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) - erase_entered_value(input_field=hr) - enter_keypad_value(entry=str(heart_rate)) + erase_entered_value(hr) + enter_keypad_value(str(heart_rate)) verify_entered_value_in_pop_up(value=str(heart_rate), input_field=hr, vital=HEART_RATE_TITLE) verify_color_of_entry(entry=heart_rate, vital_parameter=HEART_RATE_TITLE, @@ -300,8 +269,7 @@ if save: test.log("Clicking confirm button") confirm_button = waitForObjectExists(names.o_vitals_confrim_btn) - test.compare(confirm_button.enabled, True, "Valid Blood Pressure and " + - "and Heart is entered therefore confirm button is enabled") + test.compare(confirm_button.enabled, True, "Valid Blood Pressure and Heart is entered therefore confirm button is enabled") saved_time = get_current_date_and_time() mouseClick(confirm_button) verify_last_read_time(saved_time)