Index: tst_unhandled_message_log/test.py =================================================================== diff -u -r79c4043b5b7174481a3ec7826d114a98dbfe3100 -r9a6da8481fcb326cf31365772bedcc411100028a --- tst_unhandled_message_log/test.py (.../test.py) (revision 79c4043b5b7174481a3ec7826d114a98dbfe3100) +++ tst_unhandled_message_log/test.py (.../test.py) (revision 9a6da8481fcb326cf31365772bedcc411100028a) @@ -34,9 +34,10 @@ DUMMY_INT_VALUE_2 = 32 DUMMY_UNSIGNED_INT_VALUE = 5 -UNHANDLED_MESSAGE_1 = "\n[0xBB00]\nHD_custom_data_verification_1\nU32=unsigned_32bit\nU32=argument_2\n" -UNHANDLED_MESSAGE_2 = "\n[0xAA00]\nHD_custom_data_verification_2\nF32=float_argument\nS32=argument_2\n" - +UNHANDLED_MESSAGE = { + 'MESSAGE_1' : "\n[0xBB00]\nHD_custom_data_verification_1\nU32=unsigned_32bit\nU32=argument_2\n", + 'MESSAGE_2' : "\n[0xAA00]\nHD_custom_data_verification_2\nF32=float_argument\nS32=argument_2\n" + } ERROR_MESSAGE = { "0x1300" : "Incorrect data length (9 of 32) for received Message with ID '0x1300'", "0x0900" : "Incorrect data length (9 of 20) for received Message with ID '0x0900'" @@ -114,35 +115,35 @@ test.fail("err log file is not created or log file is not created based on standard log naming format.") -def modify_unhandled_configuration_file(): +def append_unhandled_configuration_file(): """ This function is capable to write custom API's on unhandled.conf folder. unhandled.conf location = '/home/denali/Projects/application/resources/settings/Messages/Unhandled.conf' Through this method filereader act as a handler and it will write custom unhandled messages on Unhandled.conf NB: it is a single time callable method should only use before starting the application. it is mandatory - to use demodify_unhandled_configuration_file() at the end of the testcase. + to use deappend_unhandled_configuration_file() at the end of the testcase. """ with open(LOCATION, "a") as filereader: - filereader.write(UNHANDLED_MESSAGE_1) - filereader.write(UNHANDLED_MESSAGE_2) + filereader.write(UNHANDLED_MESSAGE['MESSAGE_1']) + filereader.write(UNHANDLED_MESSAGE['MESSAGE_2']) utils.waitForGUI(5) -def demodify_unhandled_configuration_file(): +def remove_unhandled_configuration_file(): """ - This function is capable to remove custom API's which is written during method "modify_unhandled_configuration_file()". + This function is capable to remove custom API's which is written during method "append_unhandled_configuration_file()". unhandled.conf location = '/home/denali/Projects/application/resources/settings/Messages/Unhandled.conf' - NB: it is a single time callable method should use only after calling "modify_unhandled_configuration_file()" method. + NB: it is a single time callable method should use only after calling "append_unhandled_configuration_file()" method. """ count = 0 - for value in UNHANDLED_MESSAGE_2: + for value in UNHANDLED_MESSAGE['MESSAGE_2']: if value == '\n': count+=1 - for value in UNHANDLED_MESSAGE_1: + for value in UNHANDLED_MESSAGE['MESSAGE_1']: if value == '\n': count+=1 with open(LOCATION, "r") as filereader: @@ -154,7 +155,7 @@ def main(): - modify_unhandled_configuration_file() + append_unhandled_configuration_file() utils.tstStart(__file__) startApplication(config.AUT_NAME) @@ -209,7 +210,7 @@ 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_1.split('\n') + 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]) @@ -226,7 +227,7 @@ payload += unsigned_integer_to_bytearray(DUMMY_UNSIGNED_INT_VALUE) hd_simulator.cmd_send_hd_general_response(message_id = 170, accepted = 1, reason = 0, is_pure_data = False, has_parameters = True, parameters_payload = payload) - unhandled_message = UNHANDLED_MESSAGE_2.split('\n') + 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]) @@ -237,7 +238,7 @@ test.verify(config.ACK_BAK_STATUS in log_data, "ack back is verified") - demodify_unhandled_configuration_file() + remove_unhandled_configuration_file() utils.tstDone()