@@ -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 ()
@@ -90,13 +101,17 @@ def test_run_get_response_not_ok(self, mock_time):
90101 d .run ()
91102 self .assertTrue ("404" in str (context .exception ))
92103
93- @patch ("time.time" , return_value = 1000 )
104+ @patch ("time.time" )
94105 def test_run_uncompressed_successful (self , mock_time ):
106+ self ._setup_time_mock_for_download (mock_time , 1000.5 )
107+
95108 http_client = DatabricksHttpClient .get_instance ()
96109 file_bytes = b"1234567890" * 10
97110 settings = Mock (link_expiry_buffer_secs = 0 , download_timeout = 0 , use_proxy = False )
98111 settings .is_lz4_compressed = False
112+ settings .min_cloudfetch_download_speed = 1.0
99113 result_link = Mock (bytesNum = 100 , expiryTime = 1001 )
114+ result_link .fileLink = "https://s3.amazonaws.com/bucket/file.arrow?token=abc123"
100115
101116 with patch .object (
102117 http_client ,
@@ -115,15 +130,19 @@ def test_run_uncompressed_successful(self, mock_time):
115130
116131 assert file .file_bytes == b"1234567890" * 10
117132
118- @patch ("time.time" , return_value = 1000 )
133+ @patch ("time.time" )
119134 def test_run_compressed_successful (self , mock_time ):
135+ self ._setup_time_mock_for_download (mock_time , 1000.2 )
136+
120137 http_client = DatabricksHttpClient .get_instance ()
121138 file_bytes = b"1234567890" * 10
122139 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 '
123140
124141 settings = Mock (link_expiry_buffer_secs = 0 , download_timeout = 0 , use_proxy = False )
125142 settings .is_lz4_compressed = True
143+ settings .min_cloudfetch_download_speed = 1.0
126144 result_link = Mock (bytesNum = 100 , expiryTime = 1001 )
145+ result_link .fileLink = "https://s3.amazonaws.com/bucket/file.arrow?token=xyz789"
127146 with patch .object (
128147 http_client ,
129148 "execute" ,
0 commit comments