Index: tst_unhandled_message_log/test.py =================================================================== diff -u -r9a6da8481fcb326cf31365772bedcc411100028a -r6a9444c4619a3fcd3fbfad05763e89e439baf345 --- tst_unhandled_message_log/test.py (.../test.py) (revision 9a6da8481fcb326cf31365772bedcc411100028a) +++ tst_unhandled_message_log/test.py (.../test.py) (revision 6a9444c4619a3fcd3fbfad05763e89e439baf345) @@ -8,10 +8,10 @@ # # file tst_inhandled_message_log # date 2022/04/09 -# author sai chaithyna ela, +# author sai chaithyna ela # joseph varghese # - +# # NOTE: # This test verifies the unhandled logs for the messages provided. # Scenarios are covered based on equivalence partitioning method of testing. @@ -44,6 +44,7 @@ } + def verify_log(api_content): """ This function is capable to verify the log data from sd-card @@ -55,11 +56,11 @@ utils.waitForGUI(5) test.log(str(api_content)) message_extracted = utility.get_current_log_details(message_ack = True, message_text = '~'+api_content) - test.log(str(message_extracted)) + parameter_index = 0 #loop to remove default arguments present in API, here it is '?' - while('?' in message_extracted[0]): - message_extracted[0].remove('?') + while('?' in message_extracted[parameter_index]): + message_extracted[parameter_index].remove('?') return message_extracted @@ -161,6 +162,7 @@ startApplication(config.AUT_NAME) #checking if the message is not in the unhandled (err) + test.startSection("verify the message is not in unhandled (err)") hd_simulator.cmd_send_hd_general_response(message_id = 275, accepted = 1, reason = 1) unhandled_status = get_error_message_from_log() test.verify(unhandled_status == True, "message is not in unhandled.conf file. verified error message from .err file") @@ -169,9 +171,11 @@ hd_simulator.cmd_send_hd_general_response(message_id = 276, accepted = 1, reason = 1) unhandled_status = get_error_message_from_log() test.verify(unhandled_status == True, "message is not in unhandled.conf file. verified error message from .err file") + test.endSection() #checking the id exists and parameters passed is not correct regarding the definition in the conf. (err) + test.startSection("verify the id exists and parameters passed is not correct regarding the definition in the conf. (err)") #0x1300 hd_simulator.cmd_send_hd_general_response(message_id = 19, accepted = 1, reason = 1) error_message = get_error_message_from_log() @@ -182,9 +186,11 @@ hd_simulator.cmd_send_hd_general_response(message_id = 9, accepted = 0, reason = 0) error_message = get_error_message_from_log() test.compare(error_message, ERROR_MESSAGE["0x0900"], "error code should be verified in log file") + test.endSection() #checking the number of parameters are correct but the type is not correct. (err) + test.startSection("verify the number of parameters are correct but the type is not correct. (err)") #0x0A00 payload = float_to_bytearray(DUMMY_FLOAT_VALUE_1) #expected negative scenario verification hd_simulator.cmd_send_hd_general_response(message_id = 10, accepted = 1, reason = 1, is_pure_data = False, has_parameters = True, parameters_payload = payload) @@ -202,20 +208,25 @@ log_data = verify_log("HD_Alarm_Information") test.verify([DUMMY_INT_VALUE_1, DUMMY_FLOAT_VALUE_1, DUMMY_FLOAT_VALUE_2, DUMMY_FLOAT_VALUE_1, DUMMY_INT_VALUE_1] not in log_data, "parameters type should show deviation in negative scenario.") + test.endSection() #checking everything is passed correctly. (log) + test.startSection("verify the log is passed correctly.") #0xBB00 + messageID_index = 1 + message_index = 2 payload = integer_to_bytearray(DUMMY_INT_VALUE_1) payload += integer_to_bytearray(DUMMY_INT_VALUE_2) hd_simulator.cmd_send_hd_general_response(message_id = 187, accepted = 1, reason = 1, is_pure_data = False, has_parameters = True, parameters_payload = payload) + unhandled_message = UNHANDLED_MESSAGE['MESSAGE_1'].split('\n') - #unhandled_message[2] is the expected message in unhandled.conf after API call - #unhandled_message[1] is the expected message id in unhandled.conf after API call - log_data = verify_log(unhandled_message[2]) - message_id = convert_message_id_from_unhandled_file_format_to_standared_format(unhandled_message[1]) - test.verify(message_id.lower() in log_data, "message id should be "+str(unhandled_message[1])) + #unhandled_message[message_index] is the expected message in unhandled.conf after API call + #unhandled_message[messageID_index] is the expected message id in unhandled.conf after API call + log_data = verify_log(unhandled_message[message_index]) + message_id = convert_message_id_from_unhandled_file_format_to_standared_format(unhandled_message[messageID_index]) + test.verify(message_id.lower() in log_data, "message id should be "+str(unhandled_message[messageID_index])) test.verify([DUMMY_INT_VALUE_1, DUMMY_INT_VALUE_2] in log_data, "API arguments should be "+str([DUMMY_INT_VALUE_1, DUMMY_INT_VALUE_2])) test.verify(config.ACK_REQ_STATUS in log_data, "ack request is verified") test.verify(config.ACK_BAK_STATUS in log_data, "ack back is verified") @@ -229,15 +240,16 @@ unhandled_message =UNHANDLED_MESSAGE['MESSAGE_2'].split('\n') #unhandled_message[2] is the expected message in unhandled.conf after API call - #unhandled_message[1] is the expected message id in unhandled.conf after API call - log_data = verify_log(unhandled_message[2]) - message_id = convert_message_id_from_unhandled_file_format_to_standared_format(unhandled_message[1]) - test.verify(message_id.lower() in log_data, "message id should be "+str(unhandled_message[1])) + #unhandled_message[messageID_index] is the expected message id in unhandled.conf after API call + + log_data = verify_log(unhandled_message[message_index]) + message_id = convert_message_id_from_unhandled_file_format_to_standared_format(unhandled_message[messageID_index]) + test.verify(message_id.lower() in log_data, "message id should be "+str(unhandled_message[messageID_index])) test.verify([DUMMY_FLOAT_VALUE_1, DUMMY_UNSIGNED_INT_VALUE] in log_data, "API arguments should be "+str([DUMMY_FLOAT_VALUE_1, DUMMY_UNSIGNED_INT_VALUE, 0])) test.verify(config.ACK_REQ_STATUS in log_data, "ack request is verified") test.verify(config.ACK_BAK_STATUS in log_data, "ack back is verified") - - + test.endSection() + remove_unhandled_configuration_file() utils.tstDone()