@@ -238,7 +238,6 @@ def setUp(self):
238238 """Set up fake filesystem for each test."""
239239 self .setUpPyfakefs ()
240240
241-
242241 @patch ('gnssanalysis.gn_download.get_earthdata_credentials' )
243242 @patch ('gnssanalysis.gn_download.check_whether_to_download' )
244243 def test_file_already_exists_skip (self , mock_check , mock_creds ):
@@ -361,20 +360,30 @@ def test_retry_logic_with_eventual_success(self, mock_sleep, mock_session, mock_
361360 mock_session_instance .get .side_effect = [mock_response_fail , mock_response_success ]
362361
363362 # Execute
364- result = download_file_from_cddis (
365- filename = "test.txt" ,
366- url_folder = "test/folder" ,
367- output_folder = output_dir ,
368- max_retries = 2 ,
369- decompress = False
363+ # Check (and don't print) warning
364+ with self .assertWarns (Warning ) as warning_assessor :
365+ result = download_file_from_cddis (
366+ filename = "test.txt" , url_folder = "test/folder" , output_folder = output_dir , max_retries = 2 , decompress = False
367+ )
368+
369+ captured_warnings = warning_assessor .warnings
370+
371+ self .assertIn ( # Backoff time is random, so can't be explicitly matched here.
372+ "Error downloading test.txt: Network error (retry 1/2, backoff" ,
373+ str (captured_warnings [0 ].message ),
374+ )
375+
376+ self .assertEqual (
377+ len (captured_warnings ),
378+ 1 ,
379+ "Expected 1 warning. Check what other warnings are being raised!" ,
370380 )
371381
372382 # Verify
373383 self .assertEqual (result , download_path )
374384 self .assertEqual (mock_session_instance .get .call_count , 2 )
375385 mock_sleep .assert_called_once () # Should sleep once between retries
376386
377-
378387 @patch ('gnssanalysis.gn_download.get_earthdata_credentials' )
379388 @patch ('gnssanalysis.gn_download.check_whether_to_download' )
380389 @patch ('requests.Session' )
0 commit comments