Index: tst_post/test.py =================================================================== diff -u -rc79559a8ecd6dc676c7aed956ba1a5d1e45534a0 -r316fd2f51b0fa89c0f69949d79ef246e1e4bc4ed --- tst_post/test.py (.../test.py) (revision c79559a8ecd6dc676c7aed956ba1a5d1e45534a0) +++ tst_post/test.py (.../test.py) (revision 316fd2f51b0fa89c0f69949d79ef246e1e4bc4ed) @@ -1,19 +1,25 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. -# copyright -# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, -# IN PART OR IN WHOLE, -# WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +########################################################################### # -# file tst_post -# @author (last) Papiya Mandal -# @date (last) 19-04-2022 +# Copyright (c) 2022-2025 Diality Inc. - All Rights Reserved. # -import names +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file test.py +# +# @author (last) Vy +# @date (last) 01-Dec-2023 +# @author (original) Behrouz NematiPour +# @date (original) 02-Jan-2022 +# +############################################################################ +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 +183,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 +275,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