@@ -227,3 +227,78 @@ def test_input_dir_copy_corpus_all_files_too_large(temp_dir, mock_node_local):
227227 # Should return empty list
228228 assert copied_files == []
229229 assert input_dir .local_corpus_count () == 0
230+
231+
232+ def test_copy_corpus_only_local (temp_dir ):
233+ """Test that copy_corpus copies only to node-local (not remote)."""
234+ remote_path = os .path .join (temp_dir , "remote" )
235+ with patch ("buttercup.common.node_local.remote_path" , return_value = remote_path ):
236+ input_dir = InputDir (temp_dir , "test_corpus" )
237+
238+ src_dir = os .path .join (temp_dir , "src_corpus" )
239+ os .makedirs (src_dir , exist_ok = True )
240+
241+ # Create a test file
242+ file_path = os .path .join (src_dir , "test_file" )
243+ with open (file_path , "wb" ) as f :
244+ f .write (b"test content" )
245+
246+ copied_files = input_dir .copy_corpus (src_dir )
247+
248+ # File should exist locally
249+ assert len (copied_files ) == 1
250+ assert os .path .exists (copied_files [0 ])
251+
252+ # Remote file should not exist
253+ remote_file = os .path .join (remote_path , os .path .basename (copied_files [0 ]))
254+ assert not os .path .exists (remote_file )
255+
256+
257+ def test_copy_file_only_local (temp_dir ):
258+ """Test that copy_file with only_local=True skips remote copy."""
259+ remote_path = os .path .join (temp_dir , "remote" )
260+ with patch ("buttercup.common.node_local.remote_path" , return_value = remote_path ):
261+ input_dir = InputDir (temp_dir , "test_corpus" )
262+
263+ src_dir = os .path .join (temp_dir , "src_corpus" )
264+ os .makedirs (src_dir , exist_ok = True )
265+
266+ # Create a test file
267+ file_path = os .path .join (src_dir , "test_file" )
268+ with open (file_path , "wb" ) as f :
269+ f .write (b"test content" )
270+
271+ # Copy file with only_local=True
272+ dst = input_dir .copy_file (file_path , only_local = True )
273+
274+ # File should exist locally
275+ assert os .path .exists (dst )
276+
277+ # Remote file should not exist
278+ remote_file = os .path .join (remote_path , os .path .basename (dst ))
279+ assert not os .path .exists (remote_file )
280+
281+
282+ def test_copy_file_with_remote (temp_dir ):
283+ """Test that copy_file with only_local=False copies to both local and remote."""
284+ remote_path = os .path .join (temp_dir , "remote" )
285+ with patch ("buttercup.common.node_local.remote_path" , return_value = remote_path ):
286+ input_dir = InputDir (temp_dir , "test_corpus" )
287+
288+ src_dir = os .path .join (temp_dir , "src_corpus" )
289+ os .makedirs (src_dir , exist_ok = True )
290+
291+ # Create a test file
292+ file_path = os .path .join (src_dir , "test_file" )
293+ with open (file_path , "wb" ) as f :
294+ f .write (b"test content" )
295+
296+ # Copy file with only_local=False (explicit)
297+ dst = input_dir .copy_file (file_path , only_local = False )
298+
299+ # File should exist locally
300+ assert os .path .exists (dst )
301+
302+ # Same file should exist in remote
303+ remote_file = os .path .join (remote_path , os .path .basename (dst ))
304+ assert os .path .exists (remote_file )
0 commit comments