# -*- 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_cloud_sync_device_registration # date 2022/07/06 # author Amol Shinde # author Akshay Dhawan # # NOTE: # This test verifies the data in the input buf file after passing HD and DG serial version import names 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() MESSAGE_ID_REQUEST = "1001" MESSAGE_ID_RESPONSE = "1002" HD_VERSION_SERIAL_RESPONSE = '1657705302,2,0,1002,3,HD1234567890123,,06300216' DG_VERSION_SERIAL_RESPONSE = '1657706417,8,0,1002,3,,DG1234567890123,06300216' HD_DG_VERSION_SERIAL_RESPONSE = "1657706421,14,0,1002,3,HD1234567890123,DG1234567890123,06300216" def verify_log_response(expected_cloudsync_request_data, expected_cloudsync_response_data): """ This function is used for verifying the expected and actual cloud-sync log data. @param: expected_cloudsync_request_data (str) list containing request message id i.e. 1001 @param: expected_cloudsync_response_data (str) list containing response message id i.e. 1002 @return: None """ DEVICE_REGISTRATION_LINES_DATA = 2 actual_cloudsync_data = utility.retrive_log_data(DEVICE_REGISTRATION_LINES_DATA) current_epoch_value = time.time() epoch_value_status = utility.get_epoch_value_consistancy(current_epoch_value, actual_cloudsync_data[0][0]) test.verify(epoch_value_status, "epoch value should be in range and it is verified") main_item = waitForObjectExists(names.o_mainItem_Item) expected_software_version = object.children(main_item)[5] if MESSAGE_ID_REQUEST in actual_cloudsync_data[1]: test.compare(expected_cloudsync_request_data[3], actual_cloudsync_data[1][3], "The message id request should be: "+expected_cloudsync_request_data[3]) if MESSAGE_ID_RESPONSE in actual_cloudsync_data[0]: expected_cloudsync_response_data = expected_cloudsync_response_data.split(',') test.compare(expected_cloudsync_response_data[3], actual_cloudsync_data[0][3], "The message id response should be: "+expected_cloudsync_response_data[3]) test.compare(expected_cloudsync_response_data[4], actual_cloudsync_data[0][4], "The number of parameters should be: "+expected_cloudsync_response_data[4]) test.compare(expected_cloudsync_response_data[5], actual_cloudsync_data[0][5], "The HD serial version should be: "+expected_cloudsync_response_data[5]) test.compare(expected_cloudsync_response_data[6], actual_cloudsync_data[0][6], "The DG serial version should be: "+expected_cloudsync_response_data[6]) test.compare(expected_software_version.text, actual_cloudsync_data[0][7], "The software version should be: "+expected_cloudsync_response_data[7]) def verify_version_registration(): """ Method to verify all the parameters generating in input buf file after passing hd version serial @param: None @return: None """ test.startSection("Verification of input buf file data for HD version serial") HD_VERSION_SERIAL_REQUEST = '1657706411,1,0,1001,3,HD1234567890123,,06300216' HD_VERSION_SERIAL_REQUEST = HD_VERSION_SERIAL_REQUEST.split(",") hd_simulator.cmd_send_serial_hd_data(serial = HD_VERSION_SERIAL_REQUEST[5]) utils.waitForGUI(2) verify_log_response(HD_VERSION_SERIAL_REQUEST, HD_VERSION_SERIAL_RESPONSE) test.endSection() test.startSection("Verification of input buf file data for DG version serial") DG_VERSION_SERIAL_REQUEST = '1657706417,7,0,1001,3,,DG1234567890123,06300216' DG_VERSION_SERIAL_REQUEST = DG_VERSION_SERIAL_REQUEST.split(",") dg_simulator.cmd_send_serial_dg_data(serial = DG_VERSION_SERIAL_REQUEST[6]) utils.waitForGUI(2) verify_log_response(DG_VERSION_SERIAL_REQUEST, DG_VERSION_SERIAL_RESPONSE) test.endSection() test.startSection("Verification of input buf file data for HD and DG version serial") HD_DG_VERSION_SERIAL_REQUEST = "1657706421,13,0,1001,3,HD1234567890123,DG1234567890123,06300216" hd_simulator.cmd_send_serial_hd_data(serial = HD_VERSION_SERIAL_REQUEST[5]) dg_simulator.cmd_send_serial_dg_data(serial = DG_VERSION_SERIAL_REQUEST[6]) HD_DG_VERSION_SERIAL_REQUEST = HD_DG_VERSION_SERIAL_REQUEST.split(",") utils.waitForGUI(2) verify_log_response(HD_DG_VERSION_SERIAL_REQUEST, HD_DG_VERSION_SERIAL_RESPONSE) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) verify_version_registration() utils.tstDone()