Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add properties for new job statistics #3721

Closed
wants to merge 15 commits into from
Closed
11 changes: 11 additions & 0 deletions bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ def __init__(self, project=None, credentials=None, _http=None):
project=project, credentials=credentials, _http=_http)
self._connection = Connection(self)

def _clone(self, project):

This comment was marked as spam.

"""Create a new client for another project.

Helper for creating dataset / table instances in remote projects.

:rtype: :class:`Client`
:returns: a new instance, bound to the supplied project, using
the same credentials / http object as this instance.
"""
return self.__class__(project, self._credentials, self._http)

This comment was marked as spam.


def list_projects(self, max_results=None, page_token=None):
"""List projects for the project associated with this client.

Expand Down
12 changes: 12 additions & 0 deletions bigquery/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ def test_ctor(self):
self.assertIs(client._connection.credentials, creds)
self.assertIs(client._connection.http, http)

def test_clone(self):
PROJECT = 'PROJECT'
OTHER_PROJECT = 'OTHER-PROJECT'
creds = _make_credentials()
http = object()
client = self._make_one(project=PROJECT, credentials=creds, _http=http)

cloned = client._clone(OTHER_PROJECT)
self.assertEqual(cloned.project, OTHER_PROJECT)
self.assertIs(cloned._credentials, creds)
self.assertIs(cloned._http, http)

def test_list_projects_defaults(self):
import six
from google.cloud.bigquery.client import Project
Expand Down