def test_get_adc_env_from_well_known(self, *stubs):
# Unpack stubs.
get_well_known, get_env_file, in_gae, in_gce = stubs
# Make sure the well-known file is an actual file.
get_well_known.return_value = __file__
# Make sure the well-known file actually doesn't exist.
self.assertTrue(os.path.exists(get_well_known.return_value))
method_name = (
'oauth2client.client.'
'_get_application_default_credential_from_file')
result_creds = object()
with mock.patch(method_name,
return_value=result_creds) as get_from_file:
result = client.GoogleCredentials.get_application_default()
self.assertEqual(result, result_creds)
get_from_file.assert_called_once_with(__file__)
get_env_file.assert_called_once_with()
get_well_known.assert_called_once_with()
in_gae.assert_not_called()
in_gce.assert_not_called()
评论列表
文章目录