@@ -119,13 +119,28 @@ def test_raises_error_for_file_outside_inputdata_root(
119119 with pytest .raises (RuntimeError , match = "not under inputdata root" ):
120120 rimport .stage_data (src , inputdata_root , staging_root )
121121
122+ def test_raises_error_for_file_outside_inputdata_root_with_special_str (
123+ self , tmp_path , inputdata_root , staging_root
124+ ):
125+ """
126+ Test that staging a file outside inputdata root raises RuntimeError, even if a certain
127+ special string is included in its path.
128+ """
129+ # Create a file outside inputdata root
130+ src = tmp_path / "outside" / "file_d651077.nc"
131+ src .parent .mkdir ()
132+ src .write_text ("data" )
133+
134+ # Should raise RuntimeError
135+ with pytest .raises (RuntimeError , match = "not under inputdata root" ):
136+ rimport .stage_data (src , inputdata_root , staging_root )
137+
122138 def test_raises_error_for_already_published_file (
123139 self , tmp_path , inputdata_root , staging_root
124140 ):
125141 """Test that staging an already published file raises RuntimeError."""
126- # Create a file with "d651077" in the path (published indicator)
127- src = tmp_path / "d651077" / "data" / "file.nc"
128- src .parent .mkdir (parents = True )
142+ # Create a file in staging_root
143+ src = staging_root / "file.nc"
129144 src .write_text ("data" )
130145
131146 # Should raise RuntimeError for already published file
0 commit comments