Index: shared/scripts/configuration/config.py =================================================================== diff -u -r98de6e3aae57ae6e06b6624fab7e183103149f33 -rcc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225 --- shared/scripts/configuration/config.py (.../config.py) (revision 98de6e3aae57ae6e06b6624fab7e183103149f33) +++ shared/scripts/configuration/config.py (.../config.py) (revision cc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225) @@ -56,9 +56,9 @@ #services PASSWORD = 123 CONFIRM_TEXT = "CONFIRM" - +SHUTDOWN_TEXT = "SHUTDOWN" OUT_OF_RANGE_COLOR = "#c53b33" IN_RANGE_COLOR = "#fcfcfc" -SERVICE_CONF_LOCATION = "/home/denali/Projects/application/resources/settings/Service.conf" +SERVICE_CONF_LOCATION = os.environ['HOME']+"/Projects/application/resources/settings/Service.conf" VALID = True INVALID = False Index: shared/scripts/configuration/utility.py =================================================================== diff -u -re722325d02c51abd72e9215a56f4623f3b1334c5 -rcc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225 --- shared/scripts/configuration/utility.py (.../utility.py) (revision e722325d02c51abd72e9215a56f4623f3b1334c5) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision cc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225) @@ -12,13 +12,15 @@ # ############################################################################ +import csv import names import sys import test import squish from configuration import config from builtins import int as pyInt from dialin.ui import utils +from datetime import datetime def check_if_object_is_within_the_container(obj=None, container=None): """ @@ -87,7 +89,7 @@ value = pyInt(value) key_val = squish.waitForObject(keyboard_input(value)) squish.mouseClick(key_val) - utils.waitForGUI(1) + utils.waitForGUI(0.1) test.endSection() def keypad_input(key_value): @@ -105,7 +107,7 @@ value = pyInt(value) key_val = squish.waitForObject(keypad_input(value)) squish.mouseClick(key_val) - utils.waitForGUI(1) + utils.waitForGUI(0.1) test.endSection() @@ -118,9 +120,207 @@ input_field= squish.waitForObject(input_field) entered_value = str(input_field.text) for value in range(len(entered_value)+1): - utils.waitForGUI(1) + utils.waitForGUI(0.1) squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) test.compare(str(input_field.text), "", "Input field should be empty") test.endSection() + +def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): + + date = datetime.now() + return str(date.strftime(date_format)) + +def is_float(num): + """ + This function checks the value is adaptable for float conversion. + + @param num - (string) input value for conversion. + @return True/False- (bool) returns True if the value can type casted into float, else False + """ + try: + if '.' in num: + float(num) + return True + except ValueError: + return False + + +def is_intiger(num): + """ + This function checks the value is adaptable for integer conversion. + + @param num - (string) (string) input value for conversion. + @return True/False- (bool) returns True if the value can type casted into int, else False + """ + try: + if num.isdigit(): + return True + except ValueError: + return False + +def get_extracted_file(): + """ + This function is the handler for getting file from log folder. + + This handler will go inside log folder and looks for newly added log based on current time. + if it satisfied that condition, it will return the exact path of newly created log. + + Application log file is automatically created on '/home/denali/Desktop/sd-card/log/ {current_date}_denaliSquish.log' + + @return latest_file - (string) returns latest file that append on log folder from sd-data + """ +# try: + current_date = get_current_date_and_time(date_format = "%Y_%m_%d") + latest_file = '/home/denali/Desktop/sd-card/log/'+current_date+'_denaliSquish.log' + return latest_file +# except: +# return False + + +def get_message_from_log(file_name, message_text): + + """ + This method intended to extract the message from application log. + For row[index], index represent column to be extracted. + + @param file_name - (string) path of the latest log file created. + @param message_text - (string) message text to be extracted. + @return message - (list) API arguments displayed in log. + """ + message = [] + count = 0 + try: + with open(file_name, 'r') as csv_file: + try: + for row in reversed(list(csv.reader(csv_file))): + if row[0].isalpha(): + pass + else: + row_length = sum(1 for values in row) + if row_length >= 4: + if row[3]!= None and row[3] == message_text: + if count == 30: + test.log("2") + test.fail("handler unable to find message text from log file.") + message_length = sum(1 for values in row) + for column in range(4, message_length, 1): + message.append(row[column]) + count +=1 + for value in range(len(message)): + float_status = is_float(message[value]) + int_status = is_intiger(message[value]) + if float_status is True: + message[value] = float(message[value]) + if int_status is True: + message[value] = int(message[value]) + return message + else: + pass + except: + test.fail("application log data is corrupted") + except: + test.fail("Log file is not created or log file is not created based on standard log naming format.") + + +def get_ack_request_details(file_name, message_text): + """ + This method intended to extract acknowledgement request status, negative requested acknowledgement + and message id from application log. + + For row[index], were index represent column to be extracted. + + @param file_name - (string) path of the latest log file created. + @param message_text - (string) message text to be extracted from log. + @return row[3] - (string) acknowledgement request status. + @return row[4] - (string) Negative requested acknowledgement value (Sq). + @return message_id - (string) formatted message id from log. + """ + try: + message_id = " ID" + with open(file_name, 'r') as csv_file: + try: + for row in reversed(list(csv.reader(csv_file))): + if row[0].isalpha(): + pass + else: + row_length = sum(1 for values in row) + if row_length == 6 and row[3] != message_text: + if row[5].split(':')[0] == message_id: + extracted_message_id = pyInt(row[5].split(':')[1], 16) + formatted_message_id = format(extracted_message_id, '#0x') + # MSG_ID_HD_DEBUG_EVENT (0xFFF1) and MSG_ID_DG_DEBUG_EVENT (0xFFF2) hex values are reversed in log. + string_format_id = str(formatted_message_id) + first_two_char = string_format_id[2:4] + last_two_char = string_format_id[-2:] + if last_two_char != '00': + return row[3], row[4], ('0x'+last_two_char+first_two_char) + else: + return row[3], row[4], formatted_message_id.replace("00", "") + else: + pass + except: + test.fail("application log data is corrupted - unable to fetch data") + except: + test.fail("Log file is not created or log file is not created based on standard log naming format.") + + +def get_bak_request_details(file_name, ack_bak_value): + """ + This method intended to extract the acknowledgement back status from application log. + + For row[index], were index represent column to be extracted. + + @param file_name - (string) path of the latest log file created. + @param ack_bak_value - (string) Positive back acknowledgement value (Sq). + @return row[3] - (string) acknowledgement back status. + """ + try: + with open(file_name, 'r') as csv_file: + try: + for row in reversed(list(csv.reader(csv_file))): + if row[0].isalpha(): + pass + else: + row_length = sum(1 for values in row) + if row_length >= 5: + if row[4] == ack_bak_value: + return row[3] + else: + pass + else: + pass + except: + test.fail("application log data is corrupted") + except: + test.fail("Log file is not created or log file is not created based on standard log naming format.") + + + +def get_current_log_details(message_ack = False, message_text = None): + """ + This function is capable to perform data analysis from application log folder. + + logs are automatically created in path :"/home/denali/Desktop/sd-card/log/*.log". + + In row[index], index represent column to be extracted. + @param message_ack - (bool) 'True' - if ack is satisfied in log / 'False' - if ack condition is not satisfied + @param message_text - (string) message text to be extracted from log. + @return content_record - (list) list contains extracted data (ack_req, ack_bak, message, message_id). + """ + content_record = [] + file_name = get_extracted_file() + test.log(str(file_name)) + if message_text != None: + message = get_message_from_log(file_name, message_text) + content_record.append(message) + if message_ack != False: + ack_req_status, ack_req_value, message_id = get_ack_request_details(file_name, message_text) + ack_bak_value = ack_req_value.replace(":-", ":") # getting negative requested ack from positive requested ack + content_record.append(ack_req_status) + content_record.append(message_id.lower()) + if message_ack != False and ack_bak_value != None: + ack_bak_status = get_bak_request_details(file_name, ack_bak_value) + content_record.append(ack_bak_status) + return content_record Index: shared/scripts/names.py =================================================================== diff -u -re722325d02c51abd72e9215a56f4623f3b1334c5 -rcc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225 --- shared/scripts/names.py (.../names.py) (revision e722325d02c51abd72e9215a56f4623f3b1334c5) +++ shared/scripts/names.py (.../names.py) (revision cc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225) @@ -70,7 +70,8 @@ o_keypad_input = {"container": o_Gui_MainView, "id": "_keyText", "type": "Text", "unnamed": 1, "visible": True} #virtal keypad back space key o_back_space_key = {"container": o_Gui_MainView, "id": "_backspaceKeyIcon", "source": "qrc:/plugins/QtQuick/VirtualKeyboard/Styles/denali/images/iBackspace.svg", "type": "Image", "unnamed": 1, "visible": True} +o_shutdown_text = {"container": o_Gui_MainView, "text": "SHUTDOWN", "type": "Text", "unnamed": 1, "visible": True} +#alarm minimize button +o_minimize_button = {"container": o_Overlay, "id": "_image", "source": "qrc:/images/iChevronDown", "type": "Image", "unnamed": 1, "visible": True} - - Index: tst_settings_date_and_time/test.py =================================================================== diff -u -r98de6e3aae57ae6e06b6624fab7e183103149f33 -rcc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225 --- tst_settings_date_and_time/test.py (.../test.py) (revision 98de6e3aae57ae6e06b6624fab7e183103149f33) +++ tst_settings_date_and_time/test.py (.../test.py) (revision cc8afc4a6f8cafd58fe7b902d8bfb6b1f1040225) @@ -40,6 +40,7 @@ MONTH_LOWER_LIMIT = 1 YEAR_UPPER_LIMIT = 2100 YEAR_LOWER_LIMIT = 1970 +DATE_AND_TIME_MESSAGE = "AdjustHDDateTime" def settings_text_obj(text): names.o_settings_home_text_obj["text"] = text @@ -94,6 +95,15 @@ password = str((waitForObjectExists(names.o_password_text_field)).text) test.compare(password, str(services_password), "Entered password should be {}".format(str(services_password))) mouseClick(waitForObjectExists(services_screen_text_obj(config.CONFIRM_TEXT))) + utils.waitForGUI(0.5) + test.log("Verifying the 'Export' button") + test.compare(str(waitForObjectExists(settings_text_obj(config.EXPORT_TEXT)).text), config.EXPORT_TEXT,"'Export' button text should be {}".format(config.EXPORT_TEXT)) + utils.waitForGUI(0.3) + mouseClick(waitForObjectExists(settings_text_obj(config.EXPORT_TEXT))) + test.compare(waitForObjectExists(settings_text_obj(config.EXPORT_TEXT)).enabled , True, "'Export' button should be enabled") + test.log("Verifying the 'Shutdown' button enabled") + test.compare(str(waitForObjectExists(names.o_shutdown_text).text), config.SHUTDOWN_TEXT,"'SHUTDOWN' button text should be {}".format(config.SHUTDOWN_TEXT)) + test.compare(waitForObjectExists(names.o_shutdown_text).enabled , True, "'SHUTDOWN' button should be enabled") test.endSection() def navigate_to_set_date_and_time(): @@ -108,30 +118,40 @@ test.compare(set_date_and_time_title.text, SET_DATE_AND_TIME_TEXT, "{} should be displayed when user is navigated to 'Set Date And Time' screen".format(SET_DATE_AND_TIME_TEXT)) test.endSection() -def verify_entered_date_and_time(hour, min, day, month, year): +def verify_entered_date_and_time(hour, min, day, month, year, valid_parameter_passed): """ Method to enter date and time and verify the - valid and invalid entries and click on confirm - button + valid and invalid entries + @param hour - (str) Hour + @param min - (str) Minute + @param day - (str) Day + @param month - (str) Month + @param year - (str) Year + @param valid_paramter_passed - (bool) True/False whether hour/minute/day/month/year is valid """ + test.startSection("Enter date and time and verify the valid and invalid entries") date_time_column = waitForObjectExists(names.o_date_time_container) date_time_column_children = object.children(date_time_column) - time_row = date_time_column_children[0] - date_row = date_time_column_children[1] + ITEM_0_TIME_ROW = 0 + ITEM_1_DATE_ROW = 1 + TITLE_OBJECT_ITEM_NUMBER_0 = 0 + time_row = date_time_column_children[ITEM_0_TIME_ROW] + date_row = date_time_column_children[ITEM_1_DATE_ROW] time_row_children = object.children(time_row) date_row_children = object.children(date_row) - time_title_text = time_row_children[0] - date_title_text = date_row_children[0] + time_title_text = time_row_children[TITLE_OBJECT_ITEM_NUMBER_0] + date_title_text = date_row_children[TITLE_OBJECT_ITEM_NUMBER_0] test.log("Verifying time title text") test.compare(time_title_text.text, TIME_TITLE, "{} shoule be the time title text".format(TIME_TITLE)) test.log("Verifying date title text") test.compare(date_title_text.text, DATE_TITLE_TEXT, "{} should be the date title text".format(DATE_TITLE_TEXT)) hour_parent = time_row_children[1] hour_parent_children = object.children(hour_parent) - hour_input_field = hour_parent_children[1] + INPUT_FIELD_INDEX = 1 + hour_input_field = hour_parent_children[INPUT_FIELD_INDEX] minute_parent = time_row_children[-1] minute_parent_children = object.children(minute_parent) - minute_input_field = minute_parent_children[1] + minute_input_field = minute_parent_children[ INPUT_FIELD_INDEX] test.log("Entering hour") utils.waitForGUI(0.5) mouseClick(hour_input_field) @@ -145,15 +165,18 @@ utility.enter_keypad_value(min) test.compare(minute_input_field.text, min, "Minute value should be {}".format(min)) verify_color_of_entry(entry=min, date_time_parameter=MINUTE_TEXT, input_field=minute_input_field) - month_parent = date_row_children[1] + MONTH_PARENT_INDEX = 1 + DAY_PARENT_INDEX = 3 + YEAR_PARENT_INDEX = -1 + month_parent = date_row_children[MONTH_PARENT_INDEX] month_children = object.children(month_parent) - month_input_field = month_children[1] - day_parent = date_row_children[3] + month_input_field = month_children[INPUT_FIELD_INDEX] + day_parent = date_row_children[DAY_PARENT_INDEX] day_children = object.children(day_parent) - day_input_field = day_children[1] - year_parent = date_row_children[-1] + day_input_field = day_children[INPUT_FIELD_INDEX] + year_parent = date_row_children[YEAR_PARENT_INDEX] year_children = object.children(year_parent) - year_input_field = year_children[1] + year_input_field = year_children[INPUT_FIELD_INDEX] test.log("Entering Month") mouseClick(month_input_field) utility.erase_entered_value(month_input_field) @@ -172,8 +195,9 @@ utility.enter_keypad_value(year) test.compare(year_input_field.text, year, "Year value should be {}".format(year)) verify_color_of_entry(entry=year, date_time_parameter=YEAR_TEXT, input_field=year_input_field) + verify_confirm_btn(valid_parameter_passed) + test.endSection() - def verify_color_of_entry(entry, date_time_parameter, input_field): """ Method to verify the color of entry @@ -231,22 +255,14 @@ navigate_to_settings_screen() navigate_to_services_password_screen_and_enter_password() navigate_to_set_date_and_time() - verify_entered_date_and_time(hour="12", min="33", day="1", month="3", year="2022") - verify_confirm_btn(config.VALID) - verify_entered_date_and_time(hour="24", min="33", day="1", month="3", year="2022") - verify_confirm_btn(config.INVALID) - verify_entered_date_and_time(hour="00", min="60", day="1", month="3", year="2022") - verify_confirm_btn(config.INVALID) - verify_entered_date_and_time(hour="13", min="33", day="32", month="3", year="2022") - verify_confirm_btn(config.INVALID) - verify_entered_date_and_time(hour="13", min="33", day="4", month="13", year="2022") - verify_confirm_btn(config.INVALID) - verify_entered_date_and_time(hour="22", min="33", day="22", month="12", year="2101") - verify_confirm_btn(config.INVALID) - verify_entered_date_and_time(hour="22", min="33", day="22", month="12", year="1969") - verify_confirm_btn(config.INVALID) - verify_entered_date_and_time(hour="23", min="12", day="7", month="8", year="1977") - verify_confirm_btn(config.VALID) + verify_entered_date_and_time(hour="24", min="33", day="1", month="3", year="2022", valid_parameter_passed=config.INVALID) + verify_entered_date_and_time(hour="00", min="60", day="1", month="3", year="2022", valid_parameter_passed=config.INVALID) + verify_entered_date_and_time(hour="13", min="33", day="32", month="3", year="2022", valid_parameter_passed=config.INVALID) + verify_entered_date_and_time(hour="13", min="33", day="4", month="13", year="2022", valid_parameter_passed=config.INVALID) + verify_entered_date_and_time(hour="22", min="33", day="22", month="12", year="2101", valid_parameter_passed=config.INVALID) + verify_entered_date_and_time(hour="22", min="33", day="22", month="12", year="1969", valid_parameter_passed=config.INVALID) + verify_entered_date_and_time(hour="23", min="12", day="7", month="8", year="1977", valid_parameter_passed=config.VALID) + utility.get_current_log_details(message_text=DATE_AND_TIME_MESSAGE) + utils.tstDone() - - +