1414from unittest .mock import patch , MagicMock
1515from fastapi .testclient import TestClient
1616
17-
1817with patch ("intelmq.lib.utils.get_intelmq_settings" , MagicMock (return_value = {})):
1918
2019 from intelmq .app import dependencies
@@ -97,7 +96,11 @@ def setUp(self) -> None:
9796 dependencies .startup (DummyConfig ())
9897 self .conf_dir = TemporaryDirectory ()
9998 app .dependency_overrides [runner ] = get_dummy_reader (
100- paths = {"CONFIG_DIR" : self .conf_dir .name })
99+ paths = {
100+ "CONFIG_DIR" : self .conf_dir .name ,
101+ "POSITIONS_FILE" : os .path .join (self .conf_dir .name , "positions.json" )
102+ }
103+ )
101104
102105 self .save_runtime ()
103106 self .save_positions ()
@@ -110,9 +113,12 @@ def save_runtime(self):
110113 with open (f"{ self .conf_dir .name } /runtime.yaml" , "w+" ) as f :
111114 json .dump ({}, f )
112115
116+ def load_positions (self ):
117+ with open (f"{ self .conf_dir .name } /positions.json" ) as f :
118+ return json .load (f )
119+
113120 def save_positions (self ):
114- os .makedirs (f"{ self .conf_dir .name } /manager" , exist_ok = True )
115- with open (f"{ self .conf_dir .name } /manager/positions.conf" , "w+" ) as f :
121+ with open (f"{ self .conf_dir .name } /positions.json" , "w+" ) as f :
116122 json .dump ({}, f )
117123
118124 def tearDown (self ) -> None :
@@ -141,7 +147,6 @@ def test_post_runtime(self):
141147
142148 self .assertEqual (response .status_code , 200 )
143149 self .assertEqual (response .text , "success" )
144-
145150 self .assertEqual (utils .get_runtime (), data )
146151
147152 def test_post_positions (self ):
@@ -155,10 +160,7 @@ def test_post_positions(self):
155160
156161 self .assertEqual (response .status_code , 200 )
157162 self .assertEqual (response .text , "success" )
158-
159- with open (f"{ self .conf_dir .name } /manager/positions.conf" , "r" ) as f :
160- saved = json .load (f )
161- self .assertEqual (saved , data )
163+ self .assertEqual (self .load_positions (), data )
162164
163165
164166class TestAPILogin (TestCase ):
0 commit comments