# -*- coding: utf-8 -*- ## # Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. # copyright # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # file tst_UI_log_verification # date 2022/07/06 # author Amol Pandharinath Shinde # author Akshay Dhawan # # NOTE: # This test verifies the logs for the messages provided from builtins import int as pyInt from configuration import utility from configuration import config from dialin.ui import HDSimulator from dialin.ui import DGSimulator from dialin.ui import utils import time hd_simulator = HDSimulator() dg_simulator = DGSimulator() EXPECTED_NUMBER_OF_PARAMETERS = "3" MESSAGE_ID_REQUEST = "1001" MESSAGE_ID_RESPONSE = "1002" EXPECTED_SOFTWARE_VERSION = "06300216" def retrive_input_buf_file_data(): """ Method to get all the parameter values from input buf file @return: actual_epoch, actual_message_id_response, actual_parameters, actual_hd_version_serial, actual_dg_version_serial, actual_sw_version, message_id_request """ first_input_buf_line = utility.retrive_log_data(readline_count = 2) actual_epoch = first_input_buf_line[0][0] actual_message_id_response = first_input_buf_line[0][3] actual_parameters = first_input_buf_line[0][4] actual_hd_version_serial = first_input_buf_line[0][5] actual_dg_version_serial = first_input_buf_line[0][6] actual_sw_version = first_input_buf_line[0][7] message_id_request = first_input_buf_line[1][3] return (actual_epoch, actual_message_id_response, actual_parameters, actual_hd_version_serial, actual_dg_version_serial, actual_sw_version, message_id_request) def verify_inp_buf_data(actual_epoch, actual_message_id_response, actual_parameters, actual_sw_version, message_id_request): """ Method to verify and compare epoch value, number of parameters and software version from input buf file @param actual_epoch: (str) Date and Time in epoch format @param actual_message_id_response: (str) message id response from inp_buf file @param actual_parameters: (str) number of parameters @param actual_sw_version: (str) software version @param message_id_request: (str) message id request from inp_buf file @return: None """ expected_epoch_value = time.time() epoch_value_status=utility.get_epoch_value_consistancy(pyInt(actual_epoch), expected_epoch_value) test.verify(epoch_value_status, "epoch value should be in range and it is verified") test.compare(message_id_request, MESSAGE_ID_REQUEST, "The message id request should be: "+MESSAGE_ID_REQUEST) test.compare(actual_message_id_response, MESSAGE_ID_RESPONSE, "The message id response should be: "+MESSAGE_ID_RESPONSE) test.compare(actual_parameters, EXPECTED_NUMBER_OF_PARAMETERS, "The number of parameters should be: "+EXPECTED_NUMBER_OF_PARAMETERS) test.compare(actual_sw_version, EXPECTED_SOFTWARE_VERSION, "The software version should be: "+EXPECTED_SOFTWARE_VERSION) def verify_hd_version_registration(): """ Method to verify all the parameters generating in input buf file after passing hd version serial """ test.startSection("Verification of input buf file data for HD version serial") for value in range (3): hd_simulator.cmd_send_serial_hd_data(serial = config.CLOUD_SYNC["HD_VERSION_SERIAL"][value]) utils.waitForGUI(2) actual_epoch, actual_message_id_response, actual_parameters, actual_hd_version_serial, actual_dg_version_serial, actual_sw_version, message_id_request = retrive_input_buf_file_data() test.compare(actual_hd_version_serial, config.CLOUD_SYNC["HD_VERSION_SERIAL"][value], "The HD serial version should be: "+config.CLOUD_SYNC["HD_VERSION_SERIAL"][value]) verify_inp_buf_data(actual_epoch, actual_message_id_response, actual_parameters, actual_sw_version, message_id_request) test.endSection() def verify_dg_version_registration(): """ Method to verify all the parameters generating in input buf file after passing dg version serial """ test.startSection("Verification of input buf file data for DG version serial") for value in range (3): dg_simulator.cmd_send_serial_dg_data(serial = config.CLOUD_SYNC["DG_VERSION_SERIAL"][value]) utils.waitForGUI(2) actual_epoch, actual_message_id_response, actual_parameters, actual_hd_version_serial, actual_dg_version_serial, actual_sw_version, message_id_request = retrive_input_buf_file_data() test.compare(actual_dg_version_serial, config.CLOUD_SYNC["DG_VERSION_SERIAL"][value], "The DG serial version should be: "+config.CLOUD_SYNC["DG_VERSION_SERIAL"][value]) verify_inp_buf_data(actual_epoch, actual_message_id_response, actual_parameters, actual_sw_version, message_id_request) test.endSection() def verify_hd_dg_version_registration(): """ Method to verify all the parameters generating in input buf file after passing both hd and dg version serial """ test.startSection("Verification of input buf file data for HD and DG version serial") for value in range (3): hd_simulator.cmd_send_serial_hd_data(serial = config.CLOUD_SYNC["HD_VERSION_SERIAL"][value]) dg_simulator.cmd_send_serial_dg_data(serial = config.CLOUD_SYNC["DG_VERSION_SERIAL"][value]) utils.waitForGUI(2) actual_epoch, actual_message_id_response, actual_parameters, actual_hd_version_serial, actual_dg_version_serial, actual_sw_version, message_id_request = retrive_input_buf_file_data() test.compare(actual_hd_version_serial, config.CLOUD_SYNC["HD_VERSION_SERIAL"][value], "The HD serial version should be: "+config.CLOUD_SYNC["HD_VERSION_SERIAL"][value]) test.compare(actual_dg_version_serial, config.CLOUD_SYNC["DG_VERSION_SERIAL"][value], "The DG serial version should be: "+config.CLOUD_SYNC["DG_VERSION_SERIAL"][value]) verify_inp_buf_data(actual_epoch, actual_message_id_response, actual_parameters, actual_sw_version, message_id_request) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) verify_hd_version_registration() verify_dg_version_registration() verify_hd_dg_version_registration() utils.tstDone()