Index: tst_cloud_sync_device_registration/test.py =================================================================== diff -u -r705e0873df7444eadfa85a3af24670b445b6c1c3 -r15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a --- tst_cloud_sync_device_registration/test.py (.../test.py) (revision 705e0873df7444eadfa85a3af24670b445b6c1c3) +++ tst_cloud_sync_device_registration/test.py (.../test.py) (revision 15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a) @@ -15,14 +15,19 @@ # NOTE: # This test verifies the logs for the messages provided - -from builtins import int as pyInt -from configuration import utility -from configuration import config +import builtins +import csv from dialin.ui import HDSimulator from dialin.ui import DGSimulator from dialin.ui import utils +from configuration import utility +from configuration import config +from builtins import int as pyInt +from builtins import str as pyStr +from time import * import time +from datetime import datetime +from datetime import * hd_simulator = HDSimulator() dg_simulator = DGSimulator() @@ -37,6 +42,7 @@ 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] @@ -46,6 +52,29 @@ 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 epoch_value_conversion(epoch): + """ + Method to convert input buf files epoch value into date and time format + @param epoch: (int) Date and Time in epoch format + @return: epoch value in date and time format + """ + x = strftime('%Y-%m-%d %H:%M:%S', localtime(epoch)) + + #x = datetime.now() + y = x + timedelta(0,5) + z = x - timedelta(0,5) + test.log(str(x.time())) + test.log(str(y.time())) + test.log(str(z.time())) + + +# date_time_format = time.strftime('%Y-%m-%d %H:%M', time.localtime(epoch)) +# date_time_1 = date_time_format + datetime.timedelta(0,5) +# date_time_2 = date_time_format + datetime.timedelta(0,-5) +# test.log(str(date_time_1)) +# test.log(str(date_time_2)) +# return date_time_format def verify_inp_buf_data(actual_epoch, actual_message_id_response, actual_parameters, actual_sw_version, message_id_request): """ @@ -57,9 +86,12 @@ @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") + + #if epoch_value isIn range() + #EXPECTED_EPOCH = epoch_value_conversion(1657604640) + actual_epoch = builtins.int(actual_epoch) + actual_epoch = epoch_value_conversion(actual_epoch) + test.compare(actual_epoch, EXPECTED_EPOCH, "The epoch should be: "+EXPECTED_EPOCH) 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) @@ -69,6 +101,7 @@ """ 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]) @@ -82,6 +115,7 @@ """ 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]) @@ -95,6 +129,7 @@ """ 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])