Index: tst_cloud_sync_hd_opmode/test.py =================================================================== diff -u -ref47ff894b41fbe6a0ac7c2bd44641a36445476f -ra20cd43aecdf785029b1d01c5e224b1e1728261e --- tst_cloud_sync_hd_opmode/test.py (.../test.py) (revision ef47ff894b41fbe6a0ac7c2bd44641a36445476f) +++ tst_cloud_sync_hd_opmode/test.py (.../test.py) (revision a20cd43aecdf785029b1d01c5e224b1e1728261e) @@ -40,6 +40,33 @@ PEM_FILES = ['1.pem', '2.pem', '3.pem' ] +def get_cloud_sync_input_file(): + """ + This function is the handler for getting file from log folder. + Application log file is automatically created on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.log' + @return latest_file - (string) returns latest file that append on log folder from sd-data + """ + try: + current_date = utility.get_current_date_and_time(date_format = "%Y_%m_%d") + latest_file = CLOUD_SYNC_LOG_LOCATION+current_date+'_inp.buf' + return latest_file + except: + return False + + +def get_cloud_sync_output_file(): + """ + This function is the handler for getting file from log folder. + Application log file is automatically created on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_out.log' + @return latest_file - (string) returns latest file that append on log folder from sd-data + """ + try: + current_date = utility.get_current_date_and_time(date_format = "%Y_%m_%d") + latest_file = CLOUD_SYNC_LOG_LOCATION+current_date+'_out.buf' + return latest_file + except: + return False + def append_cloudsync_credentials_file(): try: @@ -61,10 +88,10 @@ test.log("Fault mode") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_FAUL.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) - test.log("Service Screen") - hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) - utils.waitForGUI(1) - test.log("Initial Screen") +# test.log("Service Screen") +# hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) +# utils.waitForGUI(1) +# test.log("Initial Screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_INIT.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Standby mode") @@ -92,12 +119,43 @@ # test.endSection() +def retrive_log_data(): + + file_name = utility.get_extracted_file_inp_buf() + try: + with open(file_name,mode = 'r') as f: + contents = csv.reader(f) + try: + for reader in reversed(list(contents)): + test.log(str(reader)) + return (reader[0],reader[1],reader[2],reader[3],reader[4],reader[5],reader[6],reader[7]) + except: + test.fail("application log data is corrupted") + except: + test.fail("Log file is not created or log file is not created based on standard log naming format.") + + +# def set_data_in_cloud_sync_output_file(location, message): +# """ +# This function is capable to write message into cloud sync folder. +# +# Through this method file reader act as a handler and it will write custom messages into {current_date}_out.buf +# """ +# with open(LOCATION, "a") as filereader: +# filereader.write(UNHANDLED_MESSAGE[message]) +# utils.waitForGUI(5) + + + def main(): append_cloudsync_credentials_file() utils.tstStart(__file__) startApplication(config.AUT_NAME) utils.waitForGUI(1.5) - navigate_to_hd_opmode_() \ No newline at end of file + navigate_to_hd_opmode_() + cloud_out_log = get_cloud_sync_output_file() + set_data_in_cloud_sync_output_file(cloud_out_log, MESSAGE_1) + retrive_log_data \ No newline at end of file