@@ -560,7 +560,24 @@ def test_fetch_plain_tle_two_sources(self, requests):
560560 assert "source_2" in res
561561 assert len (res ["source_2" ]) == 1
562562 assert mock .call ("mocked_url_1" , timeout = 15 ) in requests .get .mock_calls
563- assert len (requests .get .mock_calls ) == 4
563+ assert len ([c for c in requests .get .mock_calls if c .args ]) == 4
564+
565+ @mock .patch ("logging.error" )
566+ @mock .patch ("pyorbital.tlefile.requests.get" )
567+ def test_fetch_plain_tle_timeout (self , requests_get , logging_error ):
568+ """Test that timeout is logged."""
569+ from requests .exceptions import Timeout
570+
571+ requests_get .side_effect = Timeout
572+
573+ self .dl .config ["downloaders" ] = FETCH_PLAIN_TLE_CONFIG
574+
575+ res = self .dl .fetch_plain_tle ()
576+ for url in ["mocked_url_1" , "mocked_url_2" , "mocked_url_3" , "mocked_url_4" ]:
577+ expected = mock .call (f"Failed to make request to { url } within 15 seconds!" )
578+ assert expected in logging_error .mock_calls
579+ assert not res ["source_1" ]
580+ assert not res ["source_2" ]
564581
565582 @mock .patch ("pyorbital.tlefile.requests" )
566583 def test_fetch_plain_tle_server_is_a_teapot (self , requests ):
@@ -580,7 +597,7 @@ def test_fetch_plain_tle_server_is_a_teapot(self, requests):
580597 assert len (res ["source_2" ]) == 0
581598
582599 assert mock .call ("mocked_url_1" , timeout = 15 ) in requests .get .mock_calls
583- assert len (requests .get .mock_calls ) == 4
600+ assert len ([ c for c in requests .get .mock_calls if c . args ] ) == 4
584601
585602 @mock .patch ("pyorbital.tlefile.requests" )
586603 def test_fetch_spacetrack_login_fails (self , requests ):
0 commit comments