Index: tst_post/test.py =================================================================== diff -u -r28ad9516f9b49f928dc1c3c0adb08ed86a64ce10 -rc79559a8ecd6dc676c7aed956ba1a5d1e45534a0 --- tst_post/test.py (.../test.py) (revision 28ad9516f9b49f928dc1c3c0adb08ed86a64ce10) +++ tst_post/test.py (.../test.py) (revision c79559a8ecd6dc676c7aed956ba1a5d1e45534a0) @@ -13,10 +13,12 @@ from builtins import int as pyInt from configuration import config +from configuration import application_init as application_init from dialin.ui import utils from dialin.ui.dg_simulator import DGSimulator from dialin.ui.hd_simulator import HDSimulator +application_context = None hd_simulator = HDSimulator() dg_simulator = DGSimulator() @@ -105,14 +107,117 @@ test.compare(busy_indicator.enabled, True, "Waiting for a value") test.endSection() -def main(): +def test_sucessfully_load_everything_path(): + test.startSection("Testing successfully loading everything - happy path") + + is_create_mock_file = application_init.generate_mock_app_post_log_file(canBus_passed = True, + eth0_passed = True, + sdCard_passed = True, + rtc_passed = True, + wifi_passed = True, + bt_passed = True, + touch_passed = True, + shasum_passed = True, + cloudSync_passed= True, + build_version = "123.123.123", + build_id = "20230628230011") + if is_create_mock_file: + application_context = startApplication(config.AUT_NAME) - utils.tstStart(__file__) - startApplication(config.AUT_NAME) + hd_simulator.cmd_send_power_on_self_test_version_request() + post_a_message_and_verify_progress_and_completion(MSGS_AND_CONDITIONS) + check_log() + verify_ui_version() + application_context.detach() #close the application + else: + test.fail("Unable to create the mock app post file") + test.endSection() +def check_log(): + #TODO need to add body + #get_message_from_log(file_name, message_text, check_ack_bak = False): + utils.waitForGUI(10) + +def test_individual_fail_components_path(): + listOfStates = [True,True,True,True,True,True,True,True,True] + for index in range(0, len(listOfStates)): + test.startSection(f"Failing single post element index : {index}") + listOfStates[index] = False # set the next target fail + is_create_mock_file = application_init.generate_mock_app_post_log_file(canBus_passed = listOfStates[0], + eth0_passed = listOfStates[1], + sdCard_passed = listOfStates[2], + rtc_passed = listOfStates[3], + wifi_passed = listOfStates[4], + bt_passed = listOfStates[5], + touch_passed = listOfStates[6], + shasum_passed = listOfStates[7], + cloudSync_passed= listOfStates[8], + build_version = "123.123.123", + build_id = "20230628230011") + if is_create_mock_file: + application_context = startApplication(config.AUT_NAME) + hd_simulator.cmd_send_power_on_self_test_version_request() + check_log() + else: + test.fail("Unable to create the mock app post file") + + application_init.remove_mock_app_post_log_file() + listOfStates[index] = True # reset state + test.endSection() + application_context.detach() # close the application + +def test_missing_post_log_file(): + #delete the post.log file if it exists + test.startSection("Remove post.log file - missing log case") + application_init.remove_mock_app_post_log_file() + application_context = startApplication(config.AUT_NAME) hd_simulator.cmd_send_power_on_self_test_version_request() - post_a_message_and_verify_progress_and_completion(MSGS_AND_CONDITIONS) - verify_ui_version() - + check_log() + application_context.detach() #close the application + test.endSection() + + +def test_different_build_version_string(): + test.log("Note: Cannot test invalid major and minor of the version since it's unsigned int >=0") + build_versions_under_test = [{ "build_version" :"0.0.41", "isValid" :True}, + { "build_version" :"1.4.21", "isValid":False}, + { "build_version" :"123.123.41", "isValid":True}, + { "build_version" :"2.1.1", "isValid":False}, + { "build_version" :"10.10.100", "isValid":True}, + { "build_version" :"1.4.25", "isValid":False}] + for index in range(len(build_versions_under_test)): + version_testing = build_versions_under_test[index]["build_version"] + expected_valid_state = build_versions_under_test[index]["isValid"] + test.startSection(f"Test version {version_testing} expect : {expected_valid_state}") + is_create_mock_file = application_init.generate_mock_app_post_log_file(canBus_passed = True, + eth0_passed = True, + sdCard_passed = True, + rtc_passed = True, + wifi_passed = True, + bt_passed = True, + touch_passed = True, + shasum_passed = True, + cloudSync_passed= True, + build_version = version_testing, + build_id = "20230628230011") + if is_create_mock_file: + application_context = startApplication(config.AUT_NAME) + hd_simulator.cmd_send_power_on_self_test_version_request() + + #TODO need to check for the alarm triggered: 0300,UI,AlarmTriggered,HD UI POST OS version compatibility failure. + #TODO need to use expected_valid_state to determine the message expected in the logs + check_log() + + application_context.detach() #close the application + else: + test.fail("Unable to create the mock app post file") + test.endSection() + +def main(): + utils.tstStart(__file__) + test_sucessfully_load_everything_path() utils.tstDone() + test_individual_fail_components_path() + test_different_build_version_string() + test_missing_post_log_file()