Index: tst_settings_date_and_time/test.py =================================================================== diff -u -ra988dd9b14a5d9a247b8eb25980ca577880160ca -r7b7067b231357e205cafaf4ad3c6c61d5c16f2a8 --- tst_settings_date_and_time/test.py (.../test.py) (revision a988dd9b14a5d9a247b8eb25980ca577880160ca) +++ tst_settings_date_and_time/test.py (.../test.py) (revision 7b7067b231357e205cafaf4ad3c6c61d5c16f2a8) @@ -13,13 +13,12 @@ import builtins import names -import calendar from configuration import config, utility from dialin.ui.hd_simulator import HDSimulator from dialin.common.hd_defs import HDOpModes from dialin.ui import utils -from configuration.config import SERVICE_CONF_LOCATION, ENABLED +from configuration.config import SERVICE_CONF_LOCATION from calendar import isleap hd_simulator = HDSimulator() @@ -219,7 +218,7 @@ mouseClick(day_input_field) utility.erase_entered_value(day_input_field) utility.enter_keypad_value(day) - verify_valid_and_invalid_entry_and_its_color(entry=day, date_time_parameter=DAY_TEXT, input_field=day_input_field) + verify_valid_and_invalid_entry_and_its_color(entry=day, date_time_parameter=DAY_TEXT, input_field=day_input_field, month=month) test.log("Entering Year") mouseClick(year_input_field) utility.erase_entered_value(year_input_field) @@ -228,15 +227,16 @@ verify_confirm_btn(valid_parameter_passed) test.endSection() -def verify_valid_and_invalid_entry_and_its_color(entry, date_time_parameter, input_field): +def verify_valid_and_invalid_entry_and_its_color(entry, date_time_parameter, input_field, month=None): """ - Method to verify the valid and invalid color of entry - of date and time + Method to verify the valid and invalid entry of date and time + and its color @param entry: (int) user user entered value @param date_time_parameter - (str) parameter name under which user is entering value (hour/minute/day/month/year) @param input_field - (obj) object of input field + @param month - (int) value is passed when entry to entry passed to determine the number of days in month """ - test.startSection("Verify the color of {} value {}".format(date_time_parameter, entry)) + test.startSection("Verify the valid and invalid entry of date and time and its color {} value {}".format(date_time_parameter, entry)) actual_value = str(input_field.text) actual_value = builtins.int(actual_value) input_field_color = input_field.color.name @@ -246,47 +246,43 @@ test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Hour value {} is out of range, hour value should be in range of {} and {}".format(entry, HOUR_LOWER_LIMIT, HOUR_UPPER_LIMIT)) elif (entry >= HOUR_LOWER_LIMIT) and (entry <= HOUR_UPPER_LIMIT): - test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to '{}'".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color, config.IN_RANGE_COLOR, "Hour value {} is in range of {} and {}".format(entry, HOUR_LOWER_LIMIT, HOUR_UPPER_LIMIT)) elif date_time_parameter is MINUTE_TEXT: if (entry < MINUTE_LOWER_LIMIT) or (entry > MINUTE_UPPER_LIMIT): test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Minute value {} is out of range, minute value should be in range of {} and {}".format(entry, MINUTE_LOWER_LIMIT, MINUTE_UPPER_LIMIT)) elif (entry >= MINUTE_LOWER_LIMIT) and (entry <= MINUTE_UPPER_LIMIT): - test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to '{}'".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color, config.IN_RANGE_COLOR, "Minute value {} is in range of {} and {}".format(entry, MINUTE_LOWER_LIMIT, MINUTE_UPPER_LIMIT)) elif date_time_parameter is DAY_TEXT: - if (entry < DAY_LOWER_LIMIT) or (entry > DAY_UPPER_LIMIT): + if(month == 4 or month == 6 or month == 9 or month == 11): + day_upper_limit = DAY_UPPER_LIMIT - 1 + elif(month == 2 and isleap(date_time_parameter is YEAR_TEXT)): + day_upper_limit = DAY_UPPER_LIMIT - 2 + elif(month == 2): + day_upper_limit = DAY_UPPER_LIMIT - 3 + else: + day_upper_limit = DAY_UPPER_LIMIT + if (entry < DAY_LOWER_LIMIT) or (entry > day_upper_limit): test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Day value {} is out of range, Day value should be in range of {} and {}".format(entry, DAY_LOWER_LIMIT, DAY_UPPER_LIMIT)) - elif (entry >= DAY_LOWER_LIMIT) and (entry <= DAY_UPPER_LIMIT): - test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) + elif (entry >= DAY_LOWER_LIMIT) and (entry <= day_upper_limit): + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to '{}'".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color,config.IN_RANGE_COLOR, "Day value {} is in range of {} and {}".format(entry, DAY_LOWER_LIMIT, DAY_UPPER_LIMIT)) elif date_time_parameter is MONTH_TEXT: - if(entry==1 or entry==3 or entry==5 or entry==7 or entry==8 or entry==10 or entry==12): - day_upper_limit = DAY_UPPER_LIMIT - test.log("Number of days is " + str(day_upper_limit)) - elif(entry==4 or entry==6 or entry==9 or entry==11): - day_upper_limit = DAY_UPPER_LIMIT - 1 - test.log("Number of days is " + str(day_upper_limit)) - if(entry==2 and isleap(date_time_parameter is YEAR_TEXT)): - day_upper_limit = DAY_UPPER_LIMIT - 2 - test.log("Number of days is " + str(day_upper_limit)) - elif(entry==2): - day_upper_limit = DAY_UPPER_LIMIT - 3 - test.log("Number of days is " + str(day_upper_limit)) if (entry < MONTH_LOWER_LIMIT) or (entry > MONTH_UPPER_LIMIT): test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Month value {} is out of range, Month value should be in range of {} and {}".format(entry, MONTH_LOWER_LIMIT, MONTH_UPPER_LIMIT)) elif (entry >= MONTH_LOWER_LIMIT) and (entry <= MONTH_UPPER_LIMIT): - test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to '{}'".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color, config.IN_RANGE_COLOR, "Month value {} is in range of {} and {}".format(entry, MONTH_LOWER_LIMIT, MONTH_UPPER_LIMIT)) elif date_time_parameter is YEAR_TEXT: if (entry < YEAR_LOWER_LIMIT) or (entry > YEAR_UPPER_LIMIT): test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Year value {} is out of range, Year value should be in range of {} and {}".format(entry, YEAR_LOWER_LIMIT, YEAR_UPPER_LIMIT)) elif (entry >= YEAR_LOWER_LIMIT) and (entry <= YEAR_UPPER_LIMIT): - test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to '{}'".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color, config.IN_RANGE_COLOR, "Year value {} is in range of {} and {}".format(entry, YEAR_LOWER_LIMIT, YEAR_UPPER_LIMIT)) test.endSection()