Index: shared/scripts/configuration/strings.py =================================================================== diff -u -reefd61a5d338590b9ea89ef87d3a2c181e045cf5 -r705e0873df7444eadfa85a3af24670b445b6c1c3 --- shared/scripts/configuration/strings.py (.../strings.py) (revision eefd61a5d338590b9ea89ef87d3a2c181e045cf5) +++ shared/scripts/configuration/strings.py (.../strings.py) (revision 705e0873df7444eadfa85a3af24670b445b6c1c3) @@ -16,7 +16,4 @@ BLOOD_PRIMING_UNIT = "mL" BLOOD_PRIMING_VALUE_0 = "0" BLOOD_PRIMING_DEFAULT_VALUE = BLOOD_PRIMING_VALUE_0 + " " + BLOOD_PRIMING_UNIT - -#ui_logs -ACK_REQ_STATUS = 'Ack Req' -ACK_BAK_STATUS = 'Ack Bak' \ No newline at end of file + \ No newline at end of file Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a -r705e0873df7444eadfa85a3af24670b445b6c1c3 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 705e0873df7444eadfa85a3af24670b445b6c1c3) @@ -17,20 +17,21 @@ import csv def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): - + """ + Method to get current date and time. + @input date_format (str) - format of date to be retrieved. + @return (str) - date in specified format. + """ date = datetime.now() return str(date.strftime(date_format)) def get_extracted_input_buf_file(): """ - This function is the handler for getting file from cloudsync folder. - - This handler will go inside cloudsync folder and looks for newly added input buf file based on current time. - if it satisfied that condition, it will return the exact path of newly created input buf file. - - Application input buf file is automatically created in '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.buf' - - @return latest_file - (string) returns latest file that append in cloudsync folder + This function is the handler for getting file from cloudsync folder. + This handler will go inside cloudsync folder and looks for newly added input buf file based on current time. + if it satisfied that condition, it will return the exact path of newly created input buf file. + Application input buf file is automatically created in '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.buf' + @return latest_file - (string) returns latest file that append in cloudsync folder """ try: current_date = get_current_date_and_time(date_format = "%Y_%m_%d") @@ -62,8 +63,18 @@ except: test.fail("Log file is not created or log file is not created based on standard log naming format.") - - - - - +def get_epoch_value_consistancy(current_epoch_value, expected_epoch_value): + """ + This function is verify consistancy of epoch value. + @input current_epoch_value (float) - current epoch time + @input expected_epoch_value (str) - epoch time from the cloud-sync log. + @return (bool) - True/False + """ + expected_epoch_value = int(expected_epoch_value) + maximum_epoch_value = int(current_epoch_value + 25) + minimum_epoch_value = int(current_epoch_value - 25) + + if expected_epoch_value > minimum_epoch_value and expected_epoch_value < maximum_epoch_value : + return True + return False + Index: tst_cloud_sync_device_registration/test.py =================================================================== diff -u -r15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a -r705e0873df7444eadfa85a3af24670b445b6c1c3 --- tst_cloud_sync_device_registration/test.py (.../test.py) (revision 15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a) +++ tst_cloud_sync_device_registration/test.py (.../test.py) (revision 705e0873df7444eadfa85a3af24670b445b6c1c3) @@ -15,19 +15,14 @@ # NOTE: # This test verifies the logs for the messages provided -import builtins -import csv + +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 -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() @@ -42,7 +37,6 @@ 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] @@ -52,29 +46,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 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): """ @@ -86,12 +57,9 @@ @param message_id_request: (str) message id request from inp_buf file @return: None """ - - #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) + 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) @@ -101,7 +69,6 @@ """ 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]) @@ -115,7 +82,6 @@ """ 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]) @@ -129,7 +95,6 @@ """ 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])