X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tests%2Ftest_config.py;h=ce49cdc2069f5de0014fab09a1434a60d7ace28f;hb=2f4ab6cabdf283ecb03abc8d86930f0f7508ac50;hp=8eef73b47e425fe8acbaf311c10ba526b155b606;hpb=ad0576bd75b6bab07600b820c93ec46831068d91;p=ric-plt%2Fxapp-frame-py.git diff --git a/tests/test_config.py b/tests/test_config.py index 8eef73b..ce49cdc 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -19,7 +19,9 @@ import time import os from contextlib import suppress from mdclogpy import Logger -from ricxappframe.xapp_frame import RMRXapp, CONFIG_FILE_ENV + +from ricxappframe.util.constants import Constants +from ricxappframe.xapp_frame import RMRXapp mdc_logger = Logger(name=__name__) rmr_xapp_config = None @@ -41,7 +43,7 @@ def write_config_file(): def test_config_no_env(monkeypatch): init_config_file() - monkeypatch.delenv(CONFIG_FILE_ENV, raising=False) + monkeypatch.delenv(Constants.CONFIG_FILE_ENV, raising=False) def default_rmr_handler(self, summary, sbuf): pass @@ -62,12 +64,13 @@ def test_config_no_env(monkeypatch): time.sleep(3) assert not config_event_seen rmr_xapp_noconfig.stop() + rmr_xapp_noconfig = None def test_default_config_handler(monkeypatch): """Just for coverage""" init_config_file() - monkeypatch.setenv(CONFIG_FILE_ENV, config_file_path) + monkeypatch.setenv(Constants.CONFIG_FILE_ENV, config_file_path) def default_rmr_handler(self, summary, sbuf): pass @@ -81,12 +84,13 @@ def test_default_config_handler(monkeypatch): # give the work loop a chance to timeout on RMR and process the config event time.sleep(3) rmr_xapp_defconfig.stop() + rmr_xapp_defconfig = None def test_custom_config_handler(monkeypatch): # point watcher at the file init_config_file() - monkeypatch.setenv(CONFIG_FILE_ENV, config_file_path) + monkeypatch.setenv(Constants.CONFIG_FILE_ENV, config_file_path) def default_handler(self, summary, sbuf): pass @@ -113,6 +117,7 @@ def test_custom_config_handler(monkeypatch): time.sleep(3) assert change_config_event rmr_xapp_config.stop() + rmr_xapp_config = None def teardown_module(): @@ -124,8 +129,9 @@ def teardown_module(): """ os.remove(config_file_path) with suppress(Exception): - rmr_xapp_config.stop() - with suppress(Exception): - rmr_xapp_defconfig.stop() - with suppress(Exception): - rmr_xapp_noconfig.stop() + if rmr_xapp_config: + rmr_xapp_config.stop() + if rmr_xapp_defconfig: + rmr_xapp_defconfig.stop() + if rmr_xapp_noconfig: + rmr_xapp_noconfig.stop()