Index: tst_cloud_sync_device_registration/test.py =================================================================== diff -u -r705e0873df7444eadfa85a3af24670b445b6c1c3 -r813fdad9fdbc6060ecd1669a811ef9171b122741 --- tst_cloud_sync_device_registration/test.py (.../test.py) (revision 705e0873df7444eadfa85a3af24670b445b6c1c3) +++ tst_cloud_sync_device_registration/test.py (.../test.py) (revision 813fdad9fdbc6060ecd1669a811ef9171b122741) @@ -7,16 +7,15 @@ # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# file tst_UI_log_verification +# file tst_cloud_sync_device_registration # date 2022/07/06 -# author Amol Pandharinath Shinde +# author Amol Shinde # author Akshay Dhawan # # NOTE: -# This test verifies the logs for the messages provided +# This test verifies the data in the input buf file after passing HD and DG serial version -from builtins import int as pyInt from configuration import utility from configuration import config from dialin.ui import HDSimulator @@ -27,91 +26,77 @@ hd_simulator = HDSimulator() dg_simulator = DGSimulator() -EXPECTED_NUMBER_OF_PARAMETERS = "3" -MESSAGE_ID_REQUEST = "1001" -MESSAGE_ID_RESPONSE = "1002" -EXPECTED_SOFTWARE_VERSION = "06300216" +MESSAGE_ID_REQUEST = "1001" +MESSAGE_ID_RESPONSE = "1002" -def retrive_input_buf_file_data(): + +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): """ - 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 + 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 - """ - expected_epoch_value = time.time() - epoch_value_status=utility.get_epoch_value_consistancy(pyInt(actual_epoch), expected_epoch_value) + """ + 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") - 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(): + + 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_cloudsync_response_data[7], 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") - 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) + 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() -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) + 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() -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) + 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_hd_version_registration() - verify_dg_version_registration() - verify_hd_dg_version_registration() - + verify_version_registration() + utils.tstDone()