RMR update and I release step 1 of 2
[ric-plt/xapp-frame-py.git] / tests / test_config.py
index 8eef73b..ce49cdc 100644 (file)
@@ -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()