def test_client_initializes_with_impersonated_service_account(
      self, mock_impersonated_account):
    mock_impersonated_account.return_value = self.mock_credentials

    bigquery_utils.BigQueryUtils(
        project_id=self.project_id,
        service_account_name=self.service_account_name)

    mock_impersonated_account.assert_called_once_with(self.service_account_name)
    self.mock_client.assert_called_with(
        project=self.project_id, credentials=self.mock_credentials)
 def setUp(self):
   super().setUp()
   self.addCleanup(mock.patch.stopall)
   self.project_id = 'project-id'
   # Mock for google.cloud.bigquery.Client object
   self.mock_client = mock.patch.object(
       bigquery, 'Client', autospec=True).start()
   self.mock_get_credentials = mock.patch.object(
       cloud_auth, 'get_default_credentials', autospec=True).start()
   self.mock_credentials = mock.Mock(credentials.Credentials, autospec=True)
   self.mock_get_credentials.return_value = self.mock_credentials
   self.service_account_name = (
       '*****@*****.**')
   self.bigquery_client = bigquery_utils.BigQueryUtils(self.project_id)