forked from googleapis/google-cloud-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request googleapis#2809 from tseaver/2118-bigquery-allow_o…
…verride_dataset_project Allow overriding dataset's project during construction.
- Loading branch information
Showing
5 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,7 +174,7 @@ def _verifyResourceProperties(self, dataset, resource): | |
else: | ||
self.assertEqual(dataset.access_grants, []) | ||
|
||
def test_ctor(self): | ||
def test_ctor_defaults(self): | ||
client = _Client(self.PROJECT) | ||
dataset = self._make_one(self.DS_NAME, client) | ||
self.assertEqual(dataset.name, self.DS_NAME) | ||
|
@@ -196,21 +196,50 @@ def test_ctor(self): | |
self.assertIsNone(dataset.friendly_name) | ||
self.assertIsNone(dataset.location) | ||
|
||
def test_access_roles_setter_non_list(self): | ||
def test_ctor_explicit(self): | ||
from google.cloud.bigquery.dataset import AccessGrant | ||
phred = AccessGrant('OWNER', 'userByEmail', '[email protected]') | ||
bharney = AccessGrant('OWNER', 'userByEmail', '[email protected]') | ||
grants = [phred, bharney] | ||
OTHER_PROJECT = 'foo-bar-123' | ||
client = _Client(self.PROJECT) | ||
dataset = self._make_one(self.DS_NAME, client, | ||
access_grants=grants, | ||
project=OTHER_PROJECT) | ||
self.assertEqual(dataset.name, self.DS_NAME) | ||
self.assertIs(dataset._client, client) | ||
self.assertEqual(dataset.project, OTHER_PROJECT) | ||
self.assertEqual( | ||
dataset.path, | ||
'/projects/%s/datasets/%s' % (OTHER_PROJECT, self.DS_NAME)) | ||
self.assertEqual(dataset.access_grants, grants) | ||
|
||
self.assertIsNone(dataset.created) | ||
self.assertIsNone(dataset.dataset_id) | ||
self.assertIsNone(dataset.etag) | ||
self.assertIsNone(dataset.modified) | ||
self.assertIsNone(dataset.self_link) | ||
|
||
self.assertIsNone(dataset.default_table_expiration_ms) | ||
self.assertIsNone(dataset.description) | ||
self.assertIsNone(dataset.friendly_name) | ||
self.assertIsNone(dataset.location) | ||
|
||
def test_access_grants_setter_non_list(self): | ||
client = _Client(self.PROJECT) | ||
dataset = self._make_one(self.DS_NAME, client) | ||
with self.assertRaises(TypeError): | ||
dataset.access_grants = object() | ||
|
||
def test_access_roles_setter_invalid_field(self): | ||
def test_access_grants_setter_invalid_field(self): | ||
from google.cloud.bigquery.dataset import AccessGrant | ||
client = _Client(self.PROJECT) | ||
dataset = self._make_one(self.DS_NAME, client) | ||
phred = AccessGrant('OWNER', 'userByEmail', '[email protected]') | ||
with self.assertRaises(ValueError): | ||
dataset.access_grants = [phred, object()] | ||
|
||
def test_access_roles_setter(self): | ||
def test_access_grants_setter(self): | ||
from google.cloud.bigquery.dataset import AccessGrant | ||
client = _Client(self.PROJECT) | ||
dataset = self._make_one(self.DS_NAME, client) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters