Index: tst_cloud_sync - treatment_screen/test.py =================================================================== diff -u -rc4c343725fdb5ed164f5b0638d7f4dbeb0eda0c8 -rc1c94ae0f22365e44259e382e0e9d417bb8c054b --- tst_cloud_sync - treatment_screen/test.py (.../test.py) (revision c4c343725fdb5ed164f5b0638d7f4dbeb0eda0c8) +++ tst_cloud_sync - treatment_screen/test.py (.../test.py) (revision c1c94ae0f22365e44259e382e0e9d417bb8c054b) @@ -31,6 +31,59 @@ dg_simulator = DGSimulator() hd_simulator = HDSimulator() +LOCATION = '/home/denali/Projects/application/resources/settings/Messages/Unhandled.conf' + + +ERROR_MESSAGE = { +# "500" : "CS Unknown Error ", + "501" : "CS Incorrect header ", + "502" : "CS Incorrect timestamp ", + "503" : "CS Incorrect sequence ", + "504" : "CS Incorrect CRC ", + "505" : "CS Incorrect ID ", + "506" : "CS Invalid ID ", +# "507" : "CS Incorrect parameter count ", + "508" : "CS Mismatch parameter count ", + "509" : "CS Missing parameter ", + "510" : "CS No history available ", +# "511" : "CS Duplicate data ", +# "512" : "CS The log folder cannot be created. ", +# "513" : "CS Error writing to the input file. ", + "514" : "CS The credentials file does not exist. ", +# "515" : "CS The credentials folder make failed. ", +# "516" : "CS The credentials file copy failed. ", +# "517" : "CS The credentials file remove failed. ", +# "518" : "CS The credentials folder is empty. ", +# "519" : "CS No Treatment Code provided. ", + "520" : "CS The provided Treatment Code is empty. ", + "521" : "CS Out buffer empty " +} + +# eError_Unknown_500 = "1007,1," +DEVICE_FACTORY_RESET_REQUEST_1 = '' +eError_HeaderCount_501 = '1639391827,2999,3,501' +eError_Timestamp_502 = '1639391ddvgvg827,1,0,2999,0,502' +eError_Sequence_503 = '1639391827,dcdc1,0,2999,0,503' +eError_Crc_504 = '1639391827,1,0dfd,2999,0,504' +eError_MessageID_505 = '1639391827,1,0,299dfd9,0,505' +eError_InvalidID_506 = '1639391827,1,0,20,0' +# eError_ParamCount_507 = '1639391827,0,1,1006,3,507,[1,1]' +eError_ParamMismatch_508 = '1,1639391827,0,2999,0,508' +eError_ParamMissing_509 = '1639391827,1,0,2999,3,509,[8,2]' +eError_NoHistory_510 = '1639391827,1,0,2006,0' +# eErrro_Duplicate_511 = '1639391827,1,0,2999,0,511' +# eError_LogFolder_512 = '1639391827,1,0,1006,3,/tmp/credentials/dfe' +# eError_LogFileInp_513 = '1639391827,1,0,1006,3,/tmp/credentials/' +eError_CredentialMake_514 = '1657706417,7,0,2003,3,,DG1234567890123,06300216' +# eError_CredentialFile_515 = '1639391827,1,0,1006,3,/tmp/credentials/' +# eError_CredentialCopy_516 = '1639391827,1,0,1006,1,3,/tmp/credentials/' +# eError_CredentialRemove_517 = '1639391827,1,0,1006,3,/tmp/credentials/' +# eError_CredentialEmpty_518 = '1639391827,1,0,1006,3,/credentials/' +# eError_TxCodeNoParam_519 = '1639391827,1,0,1006,1,[]' +eError_TxCodeEmpty_520 = '1639391827,1,0,2008,1,' +eError_OutFileEmpty_521 = '' + + POST_TREATMENT_INSTRUCTION_COUNT = 2 CODE_DISPLAY_REQUEST = '1639391827,1,0,2008,1,Tx_code' @@ -46,7 +99,6 @@ DEVICE_HD_INFO_RESPONSE = '1639391827,1,0,1002,3,HD1234567890123,,sw_version' DEVICE_DG_INFO_RESPONSE = '1639391827,1,0,1002,3,,DG1234567890123,sw_version' - def verify_code_from_treatment_response(): """ @@ -63,8 +115,8 @@ utils.waitForGUI(1) #delay for fetching the effect text_code_label = str(waitForObjectExists(names.o_treatmentReviewConfirm_Code_Tx_code_Label).text) test.compare(message_text[config.PARAMETER_INDEX], text_code_label.split(': ')[1], "CS2UI message text for code 2008 should be verified") - - + + def set_data_in_cloud_sync_output_file(message): """ This function is capable to write message into cloud sync folder. @@ -77,7 +129,112 @@ test.log("User written message - %s into out.buf file" %message) utils.waitForGUI(3) +def verify_status(read_line): + read_line = read_line.split('[') + test.log(str(read_line[0])) + return read_line[0] + +def verify_error_message(): + +# set_data_in_cloud_sync_output_file(eError_Unknown_500) +# test.compare(str(verify_status(get_error_message_from_log())),ERROR_MESSAGE["500"], "message is not in unhandled.conf file. verified error message from .err file") +# utils.waitForGUI(2) + + set_data_in_cloud_sync_output_file(eError_HeaderCount_501) + utils.waitForGUI(2) + test.compare(str(verify_status(get_error_message_from_log())),ERROR_MESSAGE["501"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_Timestamp_502) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["502"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_Sequence_503) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["503"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_Crc_504) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["504"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_MessageID_505) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["505"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_InvalidID_506) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["506"], "message is not in unhandled.conf file. verified error message from .err file") + +# set_data_in_cloud_sync_output_file(eError_ParamCount_507) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["507"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_ParamMismatch_508) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["508"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_ParamMissing_509) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["509"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_NoHistory_510) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["510"], "message is not in unhandled.conf file. verified error message from .err file") + +# set_data_in_cloud_sync_output_file(eErrro_Duplicate_511) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["511"], "message is not in unhandled.conf file. verified error message from .err file") +# +# set_data_in_cloud_sync_output_file(eError_LogFolder_512) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["512"], "message is not in unhandled.conf file. verified error message from .err file") +# set_data_in_cloud_sync_output_file(eError_LogFileInp_513) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["513"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_CredentialMake_514) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["514"], "message is not in unhandled.conf file. verified error message from .err file") +# set_data_in_cloud_sync_output_file(eError_CredentialFile_515) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["515"], "message is not in unhandled.conf file. verified error message from .err file") +# set_data_in_cloud_sync_output_file(eError_CredentialCopy_516) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["516"], "message is not in unhandled.conf file. verified error message from .err file") +# set_data_in_cloud_sync_output_file(eError_CredentialRemove_517) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["517"], "message is not in unhandled.conf file. verified error message from .err file") +# set_data_in_cloud_sync_output_file(eError_CredentialEmpty_518) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["518"], "message is not in unhandled.conf file. verified error message from .err file") +# set_data_in_cloud_sync_output_file(eError_TxCodeNoParam_519) +# utils.waitForGUI(2) +# test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["519"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_TxCodeEmpty_520) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["520"], "message is not in unhandled.conf file. verified error message from .err file") + + set_data_in_cloud_sync_output_file(eError_OutFileEmpty_521) + utils.waitForGUI(2) + test.compare(verify_status(get_error_message_from_log()),ERROR_MESSAGE["521"], "message is not in unhandled.conf file. verified error message from .err file") + + + +def verify_log(api_content,error_message): + """ + This function is capable to verify the log data from sd-card + + @param api_content - (string) combination of message id, message text and arguments separated with '\n' + @param message_extracted - (list) list contains extracted data (ack_req, ack_bak, message, message_id). + """ + test.log(str(api_content)) + if api_content == error_message: + return True + else : + return False + + def verify_log_response(actual_cloudsync_data, expected_cloudsync_data): """ This function is used for verifying the expected and actual cloud-sync log data. @@ -94,6 +251,40 @@ for index in (config.CRC_INDEX, config.CODE_INDEX, config.PARAMETER_COUNT, config.PARAMETER_INDEX): test.compare(expected_cloudsync_data[index], actual_cloudsync_data[index], "cloud sync data %s is verified" %expected_cloudsync_data[index]) test.endSection() + +def get_error_message_from_log(): + """ + This function is capable to verify the error logs from sd-card + + @param api_content - (string) combination of message id, message text and arguments separated with '\n' + @param expected_api_argument - (list) expected arguments for API. + """ + utils.waitForGUI(5) + count = 0 + file_name = utility.get_extracted_error_file() + try: + with open(file_name, 'r') as csv_file: + try: + for row in reversed(list(csv.reader(csv_file))): + if row[0].isalpha(): + pass + else: + if count == 30: + test.fail("handler unable to find message text from error file.") + break + row_length = sum(1 for values in row) + try: + if row[1] != None: + return row[1] + + except: + pass + count+=1 + except: + test.fail("application error log data is corrupted") + except: + test.fail("err log file is not created or log file is not created based on standard log naming format.") + def main(): @@ -103,6 +294,7 @@ utils.tstStart(__file__) startApplication(config.AUT_NAME) utils.waitForGUI(1.5) + verify_error_message() main_item = waitForObjectExists(names.o_mainItem_Item) expected_software_version = str(object.children(main_item)[5]) @@ -133,7 +325,7 @@ hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_STAN.value, sub_mode=HDOpSubModes.STANDBY_WAIT_FOR_TREATMENT_STATE .value) set_data_in_cloud_sync_output_file(DEVICE_STATE_REQUEST) device_credentials_response = utility.retrive_log_data() - verify_log_response(device_credentials_response[0], DEVICE_STATE_RESPONSE) + verify_log_response(device_credentials_response[0], DEVICE_STATE_RESPONSE) utils.tstDone()