77import pytest
88from requests import RequestException
99
10- from supervisor .config import CIDFILES
10+ from supervisor .coresys import CoreSys
1111from supervisor .docker .manager import CommandReturn , DockerAPI
1212from supervisor .exceptions import DockerError
1313
@@ -138,14 +138,17 @@ async def test_run_command_custom_stdout_stderr(docker: DockerAPI):
138138 assert result .output == b"output"
139139
140140
141- async def test_run_container_with_cidfile (docker : DockerAPI , tmp_supervisor_data ):
141+ async def test_run_container_with_cidfile (
142+ coresys : CoreSys , docker : DockerAPI , path_extern , tmp_supervisor_data
143+ ):
142144 """Test container creation with cidfile and bind mount."""
143145 # Mock container
144146 mock_container = MagicMock ()
145147 mock_container .id = "test_container_id_12345"
146148
147149 container_name = "test_container"
148- cidfile_path = tmp_supervisor_data / CIDFILES / f"{ container_name } .cid"
150+ cidfile_path = coresys .config .path_cid_files / f"{ container_name } .cid"
151+ extern_cidfile_path = coresys .config .path_extern_cid_files / f"{ container_name } .cid"
149152
150153 docker .docker .containers .run .return_value = mock_container
151154
@@ -166,9 +169,9 @@ async def test_run_container_with_cidfile(docker: DockerAPI, tmp_supervisor_data
166169 kwargs = create_mock .call_args [1 ]
167170
168171 assert "volumes" in kwargs
169- assert "/run/cid" in kwargs ["volumes" ]
170- assert kwargs ["volumes" ]["/run/cid" ]["bind" ] == str ( cidfile_path )
171- assert kwargs ["volumes" ]["/run/cid" ]["mode" ] == "ro"
172+ assert str ( extern_cidfile_path ) in kwargs ["volumes" ]
173+ assert kwargs ["volumes" ][str ( extern_cidfile_path ) ]["bind" ] == "/run/cid"
174+ assert kwargs ["volumes" ][str ( extern_cidfile_path ) ]["mode" ] == "ro"
172175
173176 # Verify container start was called
174177 mock_container .start .assert_called_once ()
@@ -181,15 +184,15 @@ async def test_run_container_with_cidfile(docker: DockerAPI, tmp_supervisor_data
181184
182185
183186async def test_run_container_with_leftover_cidfile (
184- docker : DockerAPI , tmp_supervisor_data
187+ coresys : CoreSys , docker : DockerAPI , path_extern , tmp_supervisor_data
185188):
186189 """Test container creation removes leftover cidfile before creating new one."""
187190 # Mock container
188191 mock_container = MagicMock ()
189192 mock_container .id = "test_container_id_new"
190193
191194 container_name = "test_container"
192- cidfile_path = tmp_supervisor_data / "cidfiles" / f"{ container_name } .cid"
195+ cidfile_path = coresys . config . path_cid_files / f"{ container_name } .cid"
193196
194197 # Create a leftover cidfile
195198 cidfile_path .touch ()
@@ -217,15 +220,15 @@ async def test_run_container_with_leftover_cidfile(
217220
218221
219222async def test_stop_container_with_cidfile_cleanup (
220- docker : DockerAPI , tmp_supervisor_data
223+ coresys : CoreSys , docker : DockerAPI , path_extern , tmp_supervisor_data
221224):
222225 """Test container stop with cidfile cleanup."""
223226 # Mock container
224227 mock_container = MagicMock ()
225228 mock_container .status = "running"
226229
227230 container_name = "test_container"
228- cidfile_path = tmp_supervisor_data / "cidfiles" / f"{ container_name } .cid"
231+ cidfile_path = coresys . config . path_cid_files / f"{ container_name } .cid"
229232
230233 # Create a cidfile
231234 cidfile_path .touch ()
@@ -273,14 +276,16 @@ async def test_stop_container_without_removal_no_cidfile_cleanup(docker: DockerA
273276 mock_unlink .assert_not_called ()
274277
275278
276- async def test_cidfile_cleanup_handles_oserror (docker : DockerAPI , tmp_supervisor_data ):
279+ async def test_cidfile_cleanup_handles_oserror (
280+ coresys : CoreSys , docker : DockerAPI , path_extern , tmp_supervisor_data
281+ ):
277282 """Test that cidfile cleanup handles OSError gracefully."""
278283 # Mock container
279284 mock_container = MagicMock ()
280285 mock_container .status = "running"
281286
282287 container_name = "test_container"
283- cidfile_path = tmp_supervisor_data / "cidfiles" / f"{ container_name } .cid"
288+ cidfile_path = coresys . config . path_cid_files / f"{ container_name } .cid"
284289
285290 # Create a cidfile
286291 cidfile_path .touch ()
0 commit comments