@@ -23,6 +23,17 @@ class DownloaderTests(unittest.TestCase):
2323 Unit tests for checking downloader logic.
2424 """
2525
26+ def _setup_time_mock_for_download (self , mock_time , end_time ):
27+ """Helper to setup time mock that handles logging system calls."""
28+ call_count = [0 ]
29+ def time_side_effect ():
30+ call_count [0 ] += 1
31+ if call_count [0 ] <= 2 : # First two calls (validation, start_time)
32+ return 1000
33+ else : # All subsequent calls (logging, duration calculation)
34+ return end_time
35+ mock_time .side_effect = time_side_effect
36+
2637 @patch ("time.time" , return_value = 1000 )
2738 def test_run_link_expired (self , mock_time ):
2839 settings = Mock ()
@@ -75,13 +86,17 @@ def test_run_get_response_not_ok(self, mock_time):
7586 d .run ()
7687 self .assertTrue ("404" in str (context .exception ))
7788
78- @patch ("time.time" , return_value = 1000 )
89+ @patch ("time.time" )
7990 def test_run_uncompressed_successful (self , mock_time ):
91+ self ._setup_time_mock_for_download (mock_time , 1000.5 )
92+
8093 http_client = DatabricksHttpClient .get_instance ()
8194 file_bytes = b"1234567890" * 10
8295 settings = Mock (link_expiry_buffer_secs = 0 , download_timeout = 0 , use_proxy = False )
8396 settings .is_lz4_compressed = False
97+ settings .min_cloudfetch_download_speed = 1.0
8498 result_link = Mock (bytesNum = 100 , expiryTime = 1001 )
99+ result_link .fileLink = "https://s3.amazonaws.com/bucket/file.arrow?token=abc123"
85100
86101 with patch .object (
87102 http_client ,
@@ -95,15 +110,19 @@ def test_run_uncompressed_successful(self, mock_time):
95110
96111 assert file .file_bytes == b"1234567890" * 10
97112
98- @patch ("time.time" , return_value = 1000 )
113+ @patch ("time.time" )
99114 def test_run_compressed_successful (self , mock_time ):
115+ self ._setup_time_mock_for_download (mock_time , 1000.2 )
116+
100117 http_client = DatabricksHttpClient .get_instance ()
101118 file_bytes = b"1234567890" * 10
102119 compressed_bytes = b'\x04 "M\x18 h@d\x00 \x00 \x00 \x00 \x00 \x00 \x00 #\x14 \x00 \x00 \x00 \xaf 1234567890\n \x00 BP67890\x00 \x00 \x00 \x00 '
103120
104121 settings = Mock (link_expiry_buffer_secs = 0 , download_timeout = 0 , use_proxy = False )
105122 settings .is_lz4_compressed = True
123+ settings .min_cloudfetch_download_speed = 1.0
106124 result_link = Mock (bytesNum = 100 , expiryTime = 1001 )
125+ result_link .fileLink = "https://s3.amazonaws.com/bucket/file.arrow?token=xyz789"
107126 with patch .object (
108127 http_client ,
109128 "execute" ,
0 commit comments