mik-laj commented on a change in pull request #8145: Drop redundant project id
null checks.
URL: https://github.com/apache/airflow/pull/8145#discussion_r407002760
##########
File path: tests/providers/google/cloud/hooks/test_cloud_sql.py
##########
@@ -561,29 +513,6 @@ def test_get_instance_overridden_project_id(
execute_method.assert_called_once_with(num_retries=5)
wait_for_operation_to_complete.assert_not_called()
- @mock.patch(
-
'airflow.providers.google.common.hooks.base_google.GoogleBaseHook.project_id',
- new_callable=PropertyMock,
- return_value=None
- )
-
@mock.patch('airflow.providers.google.cloud.hooks.cloud_sql.CloudSQLHook.get_conn')
-
@mock.patch('airflow.providers.google.cloud.hooks.cloud_sql.CloudSQLHook._wait_for_operation_to_complete')
- def test_get_instance_missing_project_id(
- self, wait_for_operation_to_complete, get_conn, mock_project_id
- ):
- get_method = get_conn.return_value.instances.return_value.get
- execute_method = get_method.return_value.execute
- execute_method.return_value = {"name": "instance"}
- wait_for_operation_to_complete.return_value = None
- with self.assertRaises(AirflowException) as cm:
- self.cloudsql_hook_no_default_project_id.get_instance(
- instance='instance')
- get_method.assert_not_called()
- execute_method.assert_not_called()
- err = cm.exception
- self.assertIn("The project id must be passed", str(err))
- wait_for_operation_to_complete.assert_not_called()
-
Review comment:
It's possible in reality. For example: If you use ``gcloud`` for
authorization but you do not set the ``core/project`` option in gcloud,
project_id will be empty. It is not guaranteed that every service account key
must have project_id. Keys that were generated a long time ago do not have
this field.
----------------------------------------------------------------
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