@@ -485,21 +485,28 @@ def test_plugins_apis_usgs_authenticate(self, mock_api_logout, mock_api_login):
485485 USGSError ("USGS error" ),
486486 None ,
487487 ]
488- with mock .patch ("os.remove" , autospec = True ) as mock_os_remove :
488+ with (
489+ mock .patch ("os.remove" , autospec = True ) as mock_os_remove ,
490+ mock .patch ("os.path.isfile" , autospec = True ) as mock_isfile ,
491+ ):
489492 self .api_plugin .authenticate ()
490493 self .assertEqual (mock_api_login .call_count , 2 )
491494 self .assertEqual (mock_api_logout .call_count , 0 )
495+ mock_isfile .assert_called_once_with (USGS_TMPFILE )
492496 mock_os_remove .assert_called_once_with (USGS_TMPFILE )
493497 mock_api_login .reset_mock ()
494498 mock_api_logout .reset_mock ()
495499
496500 # with invalid credentials / USGSError
497501 mock_api_login .side_effect = USGSError ()
498- with mock .patch ("os.remove" , autospec = True ) as mock_os_remove :
499- with self .assertRaises (AuthenticationError ):
500- self .api_plugin .authenticate ()
501- self .assertEqual (mock_api_login .call_count , 2 )
502- mock_api_logout .assert_not_called ()
502+ with (
503+ mock .patch ("os.remove" , autospec = True ),
504+ mock .patch ("os.path.isfile" , autospec = True ),
505+ self .assertRaises (AuthenticationError ),
506+ ):
507+ self .api_plugin .authenticate ()
508+ self .assertEqual (mock_api_login .call_count , 2 )
509+ mock_api_logout .assert_not_called ()
503510
504511 @mock .patch ("usgs.api.login" , autospec = True )
505512 @mock .patch ("usgs.api.logout" , autospec = True )
@@ -635,7 +642,6 @@ def test_plugins_apis_usgs_download(
635642
636643 @responses .activate
637644 def run ():
638-
639645 product = EOProduct (
640646 "peps" ,
641647 dict (
0 commit comments