@@ -88,12 +88,12 @@ def test_preserves_directory_structure(self, inputdata_root, staging_root):
8888 assert dst .exists ()
8989 assert dst .read_text () == "nested data"
9090
91- def test_prints_live_symlink_already_published (
91+ def test_prints_live_symlink_already_published_not_downloadable (
9292 self , inputdata_root , staging_root , capsys
9393 ):
9494 """
9595 Test that staging a live, already-published symlink prints a message and returns
96- immediately without copying anything.
96+ immediately without copying anything. Should say it's not available for download.
9797 """
9898 # Create a real file in staging and a symlink to it in inputdata
9999 real_file = staging_root / "real_file.nc"
@@ -106,10 +106,12 @@ def test_prints_live_symlink_already_published(
106106 # Should print message for live symlink and return early
107107 rimport .stage_data (src , inputdata_root , staging_root )
108108
109- # Verify the right message was printed
109+ # Verify the right messages were printed
110110 stdout = capsys .readouterr ().out .strip ()
111111 msg = "File is already published and linked"
112112 assert msg in stdout
113+ msg = "File is not (yet) available for download"
114+ assert msg in stdout
113115
114116 # Verify the WRONG message was NOT printed
115117 msg = "is already under staging directory"
@@ -118,6 +120,40 @@ def test_prints_live_symlink_already_published(
118120 # Verify that shutil.copy2 was never called (function returned early)
119121 mock_copy .assert_not_called ()
120122
123+ def test_prints_live_symlink_already_published_is_downloadable (
124+ self , inputdata_root , staging_root , capsys
125+ ):
126+ """
127+ Like test_prints_live_symlink_already_published_not_downloadable, but mocks
128+ can_file_be_downloaded() to test "is available for download" message.
129+ """
130+ # Create a real file in staging and a symlink to it in inputdata
131+ real_file = staging_root / "real_file.nc"
132+ real_file .write_text ("data" )
133+ src = inputdata_root / "link.nc"
134+ src .symlink_to (real_file )
135+
136+ # Mock shutil.copy2 to verify it's never called
137+ with patch ("shutil.copy2" ) as mock_copy :
138+ # Mock can_file_be_downloaded to return True
139+ with patch ("rimport.can_file_be_downloaded" , return_value = True ):
140+ # Should print message for live symlink and return early
141+ rimport .stage_data (src , inputdata_root , staging_root )
142+
143+ # Verify that shutil.copy2 was never called (function returned early)
144+ mock_copy .assert_not_called ()
145+
146+ # Verify the right messages were printed
147+ stdout = capsys .readouterr ().out .strip ()
148+ msg = "File is already published and linked"
149+ assert msg in stdout
150+ msg = "File is available for download"
151+ assert msg in stdout
152+
153+ # Verify the WRONG message was NOT printed
154+ msg = "is already under staging directory"
155+ assert msg not in stdout
156+
121157 def test_raises_error_for_live_symlink_pointing_somewhere_other_than_staging (
122158 self , tmp_path , inputdata_root , staging_root
123159 ):
0 commit comments