Add custom configuration-change handler to qp-d
[ric-app/qp-driver.git] / tests / test_qpd.py
index ef63727..31ad001 100644 (file)
@@ -21,6 +21,8 @@ from ricxappframe.xapp_frame import Xapp, RMRXapp
 
 mock_ts_xapp = None
 mock_qp_xapp = None
+# tox.ini sets env var to this value
+config_file_path = "/tmp/config.json"
 
 """
  these tests are not currently parallelizable (do not use this tox flag)
@@ -30,6 +32,17 @@ mock_qp_xapp = None
 """
 
 
+def init_config_file():
+    with open(config_file_path, "w") as file:
+        file.write('{ "example_int" : 0 }')
+
+
+def write_config_file():
+    # generate an inotify/config event
+    with open(config_file_path, "w") as file:
+        file.write('{ "example_int" : 1 }')
+
+
 def test_init_xapp(monkeypatch, ue_metrics, cell_metrics_1, cell_metrics_2, cell_metrics_3, ue_metrics_with_bad_cell):
     # monkeypatch post_init to set the data we want in SDL
     # the metrics arguments are JSON (dict) objects
@@ -47,9 +60,16 @@ def test_init_xapp(monkeypatch, ue_metrics, cell_metrics_1, cell_metrics_2, cell
     # patch
     monkeypatch.setattr("qpdriver.main.post_init", fake_post_init)
 
+    # establish config
+    init_config_file()
+
     # start qpd
     main.start(thread=True)
 
+    # wait a bit then update config
+    time.sleep(3)
+    write_config_file()
+
 
 def test_rmr_flow(monkeypatch, qpd_to_qp, qpd_to_qp_bad_cell):
     """