title: Python Unit Testing Google Bigquery
body: <p>I am having trouble in unit testing the following code block:</p>
  
  <pre><code>from google.cloud import bigquery
  from google.oauth2 import service_account
  
  def run_query(query, gcp_ser_acc):
      credentials = 
      service_account.Credentials.from_service_account_info(gcp_ser_acc)
      client = bigquery.Client(gcp_ser_acc['project_id'], credentials)
      query_job = client.query(query)
      results = query_job.result()
      return results
  </code></pre>
  
  <p>I am new to mocking and I have tried the following test:</p>
  
  <pre><code>def test_run_a_query_with_real_key(self):
      gcp_ser_acc = {
                  'project_id': 'my_project_id',
                  'private_key': 'my_private_key',
                  'token_uri': 'my_token_uri',
                  'client_email': 'my_client_email'
                  }
      with mock.patch('service_account.Credentials', call_args=gcp_ser_acc, return_value={}):
          with mock.patch('bigquery.Client', call_args=(gcp_ser_acc['project_id'], {}), return_value={}):
              run_query('SELECT 1+1 as col', gcp_ser_acc)
              assert service_account.Credentials.called
              assert bigquery.Client.called
  </code></pre>
  
  <p>Can anybody mock the google stuff and write a unit test please?</p>