mik-laj commented on a change in pull request #5907: [AIRFLOW-5303] Use
project_id from GCP credentials
URL: https://github.com/apache/airflow/pull/5907#discussion_r319287486
##########
File path: tests/contrib/hooks/test_gcp_api_base_hook.py
##########
@@ -227,6 +229,86 @@ class TestGoogleCloudBaseHook(unittest.TestCase):
def setUp(self):
self.instance = hook.GoogleCloudBaseHook()
+ @mock.patch(MODULE_NAME + '.google.auth.default',
return_value=("CREDENTIALS", "PROJECT_ID"))
+ def test_get_credentials_and_project_id_with_default_auth(self,
mock_auth_default):
+ self.instance.extras = {}
+ result = self.instance._get_credentials_and_project_id()
+ mock_auth_default.assert_called_once_with(scopes=self.instance.scopes)
+ self.assertEqual(('CREDENTIALS', 'PROJECT_ID'), result)
+
+ @mock.patch( # type: ignore
+ MODULE_NAME +
'.google.oauth2.service_account.Credentials.from_service_account_file',
+ **{'reutnr_value.project_id': "PROJECT_ID"}
Review comment:
Fixed. I also added missing assertion.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services