@@ -154,6 +154,39 @@ def test_prints_live_symlink_already_published_is_downloadable(
154154 msg = "is already under staging directory"
155155 assert msg not in stdout
156156
157+ def test_prints_published_but_not_linked (
158+ self , inputdata_root , staging_root , capsys
159+ ):
160+ """
161+ Tests printed message for when a file has been published (copied to staging root) but not
162+ yet linked (inputdata version replaced with symlink to staging version).
163+ """
164+ # Create a real file in staging AND in inputdata
165+ filename = "real_file.nc"
166+ staged = staging_root / filename
167+ staged .write_text ("data" )
168+ inputdata = inputdata_root / filename
169+ inputdata .write_text ("data" )
170+
171+ # Mock shutil.copy2 to verify it's never called
172+ with patch ("shutil.copy2" ) as mock_copy :
173+ # Mock can_file_be_downloaded to return True
174+ with patch ("rimport.can_file_be_downloaded" , return_value = True ):
175+ # Should print message for live symlink and return early
176+ rimport .stage_data (inputdata , inputdata_root , staging_root )
177+
178+ # Verify that shutil.copy2 was never called (function returned early)
179+ mock_copy .assert_not_called ()
180+
181+ # Verify the right messages were printed or not
182+ stdout = capsys .readouterr ().out .strip ()
183+ msg = "File is already published and linked"
184+ assert msg not in stdout
185+ msg = "File is already published but NOT linked; do"
186+ assert msg in stdout
187+ msg = "File is available for download"
188+ assert msg in stdout
189+
157190 def test_raises_error_for_live_symlink_pointing_somewhere_other_than_staging (
158191 self , tmp_path , inputdata_root , staging_root
159192 ):
0 commit comments