Index: tst_post/test.py =================================================================== diff -u -rc79559a8ecd6dc676c7aed956ba1a5d1e45534a0 -r40314c67874695eefc506c3a6a33896495953edd --- tst_post/test.py (.../test.py) (revision c79559a8ecd6dc676c7aed956ba1a5d1e45534a0) +++ tst_post/test.py (.../test.py) (revision 40314c67874695eefc506c3a6a33896495953edd) @@ -10,10 +10,12 @@ # @date (last) 19-04-2022 # import names +import os from builtins import int as pyInt from configuration import config from configuration import application_init as application_init +from configuration import utility from dialin.ui import utils from dialin.ui.dg_simulator import DGSimulator from dialin.ui.hd_simulator import HDSimulator @@ -177,6 +179,58 @@ test.endSection() +def test_missing_tx_configuration_file(): + # tests the case where the DataList.conf file is missing + test.startSection(f"Testing case of missing treatment setting config file") + test.log(f"If this test is cancelled mid way before it completes, the {config.SETTINGS_ROOT_PATH}{config.TREATMENT_DATA_SETTINGS_FILENAME} is likely renamed. Please correct") + isFileRenamed = utility.rename_file(config.SETTINGS_ROOT_PATH, config.TREATMENT_DATA_SETTINGS_FILENAME, newFilename="temp_file1.conf") + if isFileRenamed: + 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("ERROR: renaming failed for test_missing_tx_configuration_file()") + + #rename the file back + utility.rename_file(config.SETTINGS_ROOT_PATH, "temp_file1.conf", newFilename=config.TREATMENT_DATA_SETTINGS_FILENAME) + + test.endSection() + +def test_empty_tx_configuration_file(): + # tests the case where the DataList.conf file is missing + test.startSection(f"Testing case of missing treatment setting config file") + test.log(f"If this test is cancelled mid way before it completes, the {config.SETTINGS_ROOT_PATH}{config.TREATMENT_DATA_SETTINGS_FILENAME} is likely renamed and empty. Please correct") + isFileRenamed = utility.rename_file(config.SETTINGS_ROOT_PATH, config.TREATMENT_DATA_SETTINGS_FILENAME, newFilename="temp_file1.conf") + + #create the empty treatment settings file + f = open(config.SETTINGS_ROOT_PATH+config.TREATMENT_DATA_SETTINGS_FILENAME, "w") + f.close() + + if isFileRenamed: + application_context = startApplication(config.AUT_NAME) + hd_simulator.cmd_send_power_on_self_test_version_request() + + #TODO need to check for the alarm triggered: To Be Fig out + #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("ERROR: renaming failed for test_missing_tx_configuration_file()") + + #rename the file back + os.remove(config.SETTINGS_ROOT_PATH+config.TREATMENT_DATA_SETTINGS_FILENAME) # remove the empty file + + utility.rename_file(config.SETTINGS_ROOT_PATH, "temp_file1.conf", newFilename=config.TREATMENT_DATA_SETTINGS_FILENAME) + + 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}, @@ -217,7 +271,13 @@ 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() + + test_missing_tx_configuration_file() + utils.waitForGUI(2) # waiting for file handling completion + test_empty_tx_configuration_file() + + utils.tstDone() \ No newline at end of file