@@ -29,13 +29,12 @@ def test_calculate_hash(is_file: bool, hash: str) -> None:
2929 "user_area" , (True , False ),
3030 ids = ("permitted_dir" , "out_of_user_area" )
3131)
32- def test_find_first_file (user_area : bool , monkeypatch : pytest .MonkeyPatch , mocker : MockerFixture ) -> None :
32+ def test_find_first_file_search (user_area : bool , monkeypatch : pytest .MonkeyPatch , mocker : MockerFixture ) -> None :
3333 # Deactivate the server checks for this test
3434 monkeypatch .setenv ("SIMVUE_NO_SERVER_CHECK" , "True" )
3535 monkeypatch .delenv ("SIMVUE_TOKEN" , False )
3636 monkeypatch .delenv ("SIMVUE_URL" , False )
3737
38-
3938 with tempfile .TemporaryDirectory () as temp_d :
4039 _path = pathlib .Path (temp_d )
4140 _path_sub = _path .joinpath ("level_0" )
@@ -57,3 +56,30 @@ def test_find_first_file(user_area: bool, monkeypatch: pytest.MonkeyPatch, mocke
5756 _path .chmod (stat .S_IRWXU )
5857 assert _result
5958
59+ @pytest .mark .config
60+ def test_find_first_file_at_root (monkeypatch : pytest .MonkeyPatch , mocker : MockerFixture ) -> None :
61+ # Deactivate the server checks for this test
62+ monkeypatch .setenv ("SIMVUE_NO_SERVER_CHECK" , "True" )
63+ monkeypatch .delenv ("SIMVUE_TOKEN" , False )
64+ monkeypatch .delenv ("SIMVUE_URL" , False )
65+
66+ @property
67+ def _returns_self (self ):
68+ return self
69+
70+
71+ with tempfile .TemporaryDirectory () as temp_d :
72+ _path = pathlib .Path (temp_d )
73+ _path_sub = _path .joinpath ("level_0" )
74+ _path_sub .mkdir ()
75+ _path .joinpath ("level_0" ).joinpath ("simvue.toml" ).touch ()
76+
77+ for i in range (1 , 5 ):
78+ _path_sub = _path_sub .joinpath (f"level_{ i } " )
79+ _path_sub .mkdir ()
80+ mocker .patch ("pathlib.Path.parent" , _returns_self )
81+ mocker .patch ("pathlib.Path.cwd" , lambda * _ : _path_sub )
82+
83+ assert not sv_util .find_first_instance_of_file ("simvue.toml" , check_user_space = False )
84+
85+
0 commit comments