{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments/36789450","id":36789450,"diff_hunk":"@@ -0,0 +1,224 @@\n+# Copyright 2015 Google Inc. All rights reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+import operator\n+import time\n+\n+import unittest2\n+\n+from gcloud import _helpers\n+from gcloud.environment_vars import TESTS_PROJECT\n+from gcloud import bigquery\n+\n+\n+_helpers.PROJECT = TESTS_PROJECT\n+CLIENT = bigquery.Client()\n+\n+\n+class TestPubsub(unittest2.TestCase):\n+\n+    def setUp(self):\n+        self.to_delete = []\n+\n+    def tearDown(self):\n+        for doomed in self.to_delete:\n+            doomed.delete()\n+\n+    def test_create_dataset(self):\n+        DATASET_NAME = 'system_tests'\n+        dataset = CLIENT.dataset(DATASET_NAME)\n+        self.assertFalse(dataset.exists())\n+        dataset.create()\n+        self.to_delete.append(dataset)\n+        self.assertTrue(dataset.exists())\n+        self.assertEqual(dataset.name, DATASET_NAME)\n+\n+    def test_patch_dataset(self):\n+        DATASET_NAME = 'system_tests'\n+        dataset = CLIENT.dataset(DATASET_NAME)\n+        self.assertFalse(dataset.exists())\n+        dataset.create()\n+        self.to_delete.append(dataset)\n+        self.assertTrue(dataset.exists())\n+        self.assertEqual(dataset.friendly_name, None)\n+        self.assertEqual(dataset.description, None)\n+        dataset.patch(friendly_name='Friendly', description='Description')\n+        self.assertEqual(dataset.friendly_name, 'Friendly')\n+        self.assertEqual(dataset.description, 'Description')\n+\n+    def test_update_dataset(self):\n+        DATASET_NAME = 'system_tests'\n+        dataset = CLIENT.dataset(DATASET_NAME)\n+        self.assertFalse(dataset.exists())\n+        dataset.create()\n+        self.to_delete.append(dataset)\n+        self.assertTrue(dataset.exists())\n+        after = [grant for grant in dataset.access_grants\n+                 if grant.entity_id != 'projectWriters']\n+        dataset.access_grants = after\n+        dataset.update()\n+        self.assertEqual(len(dataset.access_grants), len(after))\n+        for found, expected in zip(dataset.access_grants, after):\n+            self.assertEqual(found.role, expected.role)\n+            self.assertEqual(found.entity_type, expected.entity_type)\n+            self.assertEqual(found.entity_id, expected.entity_id)\n+\n+    def test_list_datasets(self):\n+        datasets_to_create = [\n+            'new%d' % (1000 * time.time(),),\n+            'newer%d' % (1000 * time.time(),),\n+            'newest%d' % (1000 * time.time(),),\n+        ]\n+        for dataset_name in datasets_to_create:\n+            dataset = CLIENT.dataset(dataset_name)\n+            dataset.create()\n+            self.to_delete.append(dataset)\n+\n+        # Retrieve the datasets.\n+        all_datasets, _ = CLIENT.list_datasets()\n+        created = [dataset for dataset in all_datasets\n+                   if dataset.name in datasets_to_create and\n+                   dataset.project == CLIENT.project]\n+        self.assertEqual(len(created), len(datasets_to_create))\n+\n+    def test_create_table(self):\n+        DATASET_NAME = 'system_tests'\n+        dataset = CLIENT.dataset(DATASET_NAME)\n+        self.assertFalse(dataset.exists())\n+        dataset.create()\n+        self.to_delete.append(dataset)\n+        TABLE_NAME = 'test_table'\n+        full_name = bigquery.SchemaField('full_name', 'STRING',\n+                                         mode='REQUIRED')\n+        age = bigquery.SchemaField('age', 'INTEGER', mode='REQUIRED')\n+        table = dataset.table(TABLE_NAME, schema=[full_name, age])\n+        self.assertFalse(table.exists())\n+        table.create()\n+        self.to_delete.insert(0, table)\n+        self.assertTrue(table.exists())\n+        self.assertEqual(table.name, TABLE_NAME)\n+        self.assertTrue(table._dataset is dataset)\n+\n+    def test_list_tables(self):\n+        DATASET_NAME = 'system_tests'\n+        dataset = CLIENT.dataset(DATASET_NAME)\n+        self.assertFalse(dataset.exists())\n+        dataset.create()\n+        self.to_delete.append(dataset)\n+        tables_to_create = [\n+            'new%d' % (1000 * time.time(),),\n+            'newer%d' % (1000 * time.time(),),\n+            'newest%d' % (1000 * time.time(),),\n+        ]\n+        full_name = bigquery.SchemaField('full_name', 'STRING',\n+                                         mode='REQUIRED')\n+        age = bigquery.SchemaField('age', 'INTEGER', mode='REQUIRED')\n+        for table_name in tables_to_create:\n+            table = dataset.table(table_name, schema=[full_name, age])\n+            table.create()\n+            self.to_delete.insert(0, table)\n+\n+        # Retrieve the tables.\n+        all_tables, _ = dataset.list_tables()\n+        created = [table for table in all_tables\n+                   if table.name in tables_to_create and\n+                   table._dataset.name == DATASET_NAME]","path":"system_tests/bigquery.py","position":136,"original_position":136,"commit_id":"57b1bd59789d36ec04e80d516f4eb20291dded77","original_commit_id":"57b1bd59789d36ec04e80d516f4eb20291dded77","user":{"login":"dhermes","id":520669,"avatar_url":"https://avatars.githubusercontent.com/u/520669?v=3","gravatar_id":"","url":"https://api.github.com/users/dhermes","html_url":"https://github.com/dhermes","followers_url":"https://api.github.com/users/dhermes/followers","following_url":"https://api.github.com/users/dhermes/following{/other_user}","gists_url":"https://api.github.com/users/dhermes/gists{/gist_id}","starred_url":"https://api.github.com/users/dhermes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhermes/subscriptions","organizations_url":"https://api.github.com/users/dhermes/orgs","repos_url":"https://api.github.com/users/dhermes/repos","events_url":"https://api.github.com/users/dhermes/events{/privacy}","received_events_url":"https://api.github.com/users/dhermes/received_events","type":"User","site_admin":false},"body":"Worth having a public accessor for `table._dataset.name`?","created_at":"2015-08-11T19:45:19Z","updated_at":"2015-08-11T19:45:19Z","html_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1047#discussion_r36789450","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments/36789450"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1047#discussion_r36789450"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047","id":41932001,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1047","diff_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1047.diff","patch_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1047.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1047","number":1047,"state":"open","locked":false,"title":"Initial BQ system tests","user":{"login":"tseaver","id":242750,"avatar_url":"https://avatars.githubusercontent.com/u/242750?v=3","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"body":"~~Uses #1046 as a base.~~","created_at":"2015-08-07T20:49:56Z","updated_at":"2015-08-11T19:45:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ede9b62c1ec51ffb08af1706898b7df8a2a0977a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1047/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/57b1bd59789d36ec04e80d516f4eb20291dded77","head":{"label":"tseaver:bigquery-system_tests","ref":"bigquery-system_tests","sha":"57b1bd59789d36ec04e80d516f4eb20291dded77","user":{"login":"tseaver","id":242750,"avatar_url":"https://avatars.githubusercontent.com/u/242750?v=3","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"repo":{"id":23322104,"name":"gcloud-python","full_name":"tseaver/gcloud-python","owner":{"login":"tseaver","id":242750,"avatar_url":"https://avatars.githubusercontent.com/u/242750?v=3","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tseaver/gcloud-python","description":"Google Cloud Python Client Library","fork":true,"url":"https://api.github.com/repos/tseaver/gcloud-python","forks_url":"https://api.github.com/repos/tseaver/gcloud-python/forks","keys_url":"https://api.github.com/repos/tseaver/gcloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tseaver/gcloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tseaver/gcloud-python/teams","hooks_url":"https://api.github.com/repos/tseaver/gcloud-python/hooks","issue_events_url":"https://api.github.com/repos/tseaver/gcloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/tseaver/gcloud-python/events","assignees_url":"https://api.github.com/repos/tseaver/gcloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/tseaver/gcloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/tseaver/gcloud-python/tags","blobs_url":"https://api.github.com/repos/tseaver/gcloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tseaver/gcloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tseaver/gcloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/tseaver/gcloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tseaver/gcloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/tseaver/gcloud-python/languages","stargazers_url":"https://api.github.com/repos/tseaver/gcloud-python/stargazers","contributors_url":"https://api.github.com/repos/tseaver/gcloud-python/contributors","subscribers_url":"https://api.github.com/repos/tseaver/gcloud-python/subscribers","subscription_url":"https://api.github.com/repos/tseaver/gcloud-python/subscription","commits_url":"https://api.github.com/repos/tseaver/gcloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/tseaver/gcloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/tseaver/gcloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/tseaver/gcloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/tseaver/gcloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/tseaver/gcloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tseaver/gcloud-python/merges","archive_url":"https://api.github.com/repos/tseaver/gcloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tseaver/gcloud-python/downloads","issues_url":"https://api.github.com/repos/tseaver/gcloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/tseaver/gcloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/tseaver/gcloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/tseaver/gcloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tseaver/gcloud-python/labels{/name}","releases_url":"https://api.github.com/repos/tseaver/gcloud-python/releases{/id}","created_at":"2014-08-25T17:19:33Z","updated_at":"2015-04-10T19:42:56Z","pushed_at":"2015-08-11T19:01:46Z","git_url":"git://github.com/tseaver/gcloud-python.git","ssh_url":"git@github.com:tseaver/gcloud-python.git","clone_url":"https://github.com/tseaver/gcloud-python.git","svn_url":"https://github.com/tseaver/gcloud-python","homepage":"http://googlecloudplatform.github.io/gcloud-python/","size":9725,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"2d017def36a2f8985d54aff1cc2984b64a922c74","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":16316451,"name":"gcloud-python","full_name":"GoogleCloudPlatform/gcloud-python","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-python","description":"Google Cloud Client Library for Python","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/releases{/id}","created_at":"2014-01-28T15:51:47Z","updated_at":"2015-08-06T12:19:14Z","pushed_at":"2015-08-11T19:03:25Z","git_url":"git://github.com/GoogleCloudPlatform/gcloud-python.git","ssh_url":"git@github.com:GoogleCloudPlatform/gcloud-python.git","clone_url":"https://github.com/GoogleCloudPlatform/gcloud-python.git","svn_url":"https://github.com/GoogleCloudPlatform/gcloud-python","homepage":"https://googlecloudplatform.github.io/gcloud-python/","size":37932,"stargazers_count":188,"watchers_count":188,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":99,"mirror_url":null,"open_issues_count":103,"forks":99,"open_issues":103,"watchers":188,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1047"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1047"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1047/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1047/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/57b1bd59789d36ec04e80d516f4eb20291dded77"}}}}