@@ -566,6 +566,86 @@ def test_merge_custom(mock_connect, mock_merge, mock_copy, mock_drop):
566
566
mock_drop .assert_called_once ()
567
567
568
568
569
+ @patch .object (Table , "_copy" )
570
+ def test_copy_custom_with_files (mock_copy ) -> None :
571
+ """Test copy_custom method with specific files parameter."""
572
+ # Setup mock to return expected result
573
+ mock_copy .return_value = [("test_file.parquet" , "LOADED" )]
574
+
575
+ # Create a table instance
576
+ table = Table (name = "TEST_TABLE" , schema_name = "TEST_SCHEMA" )
577
+
578
+ # Define column definitions
579
+ column_definitions = {
580
+ "id" : "$1:id" ,
581
+ "name" : "$1:name" ,
582
+ "last_name" : "$1:last_name" ,
583
+ }
584
+
585
+ # Test with files parameter
586
+ result = table .copy_custom (
587
+ column_definitions = column_definitions ,
588
+ path = "s3://test-bucket/path" ,
589
+ file_format = parquet_file_format ,
590
+ files = ["test_file.parquet" , "another_file.parquet" ],
591
+ )
592
+
593
+ # Verify the result
594
+ assert result [0 ][1 ] == "LOADED"
595
+
596
+ # Verify the _copy method was called with the correct query containing FILES clause
597
+ mock_copy .assert_called ()
598
+ call_args = mock_copy .call_args
599
+ query = call_args [0 ][0 ] # First positional argument is the query
600
+ assert "FILES = ('test_file.parquet', 'another_file.parquet')" in query
601
+
602
+
603
+ @patch .object (Table , "_merge" )
604
+ def test_merge_custom_with_files (mock_merge ) -> None :
605
+ """Test merge_custom method with specific files parameter."""
606
+ # Create a table instance
607
+ table = Table (name = "TEST_TABLE" , schema_name = "TEST_SCHEMA" )
608
+
609
+ # Define column definitions
610
+ column_definitions = {
611
+ "id" : "$1:id" ,
612
+ "name" : "$1:name" ,
613
+ "last_name" : "$1:last_name" ,
614
+ }
615
+
616
+ # Test merge_custom with files parameter
617
+ table .merge_custom (
618
+ column_definitions = column_definitions ,
619
+ path = "s3://test-bucket/path" ,
620
+ file_format = parquet_file_format ,
621
+ primary_keys = ["id" ],
622
+ files = ["test_file.parquet" ],
623
+ )
624
+
625
+ # Verify the _merge method was called
626
+ mock_merge .assert_called_once ()
627
+
628
+ # Get the copy_callable that was passed to _merge
629
+ call_args = mock_merge .call_args
630
+ copy_callable = call_args [0 ][0 ] # First positional argument is the copy_callable
631
+
632
+ # Now test the copy_callable to verify it passes the files parameter correctly
633
+ with patch .object (Table , "_copy" ) as mock_copy :
634
+ mock_copy .return_value = [("test_file.parquet" , "LOADED" )]
635
+
636
+ # Create a temporary table to test the copy_callable
637
+ temp_table = Table (name = "TEMP_TABLE" , schema_name = "TEST_SCHEMA" )
638
+
639
+ # Call the copy_callable (this simulates what happens inside _merge)
640
+ copy_callable (temp_table , sync_tags = False )
641
+
642
+ # Verify the _copy method was called with the correct query containing FILES clause
643
+ mock_copy .assert_called ()
644
+ call_args = mock_copy .call_args
645
+ query = call_args [0 ][0 ] # First positional argument is the query
646
+ assert "FILES = ('test_file.parquet')" in query
647
+
648
+
569
649
@patch .object (Table , "_copy" )
570
650
def test_copy_with_files (mock_copy ) -> None :
571
651
"""Test copy_into method with specific files parameter."""
0 commit comments