|
28 | 28 | DEFAULT_FILTER = 'logName:syslog AND severity>=INFO' |
29 | 29 | DEFAULT_DESCRIPTION = 'System testing' |
30 | 30 | BUCKET_NAME = 'gcloud-python-system-testing-%d' % (_MILLIS,) |
| 31 | +DATASET_NAME = 'system_testing_dataset_%d' % (_MILLIS,) |
31 | 32 |
|
32 | 33 |
|
33 | 34 | class Config(object): |
@@ -148,3 +149,29 @@ def test_create_sink_storage_bucket(self): |
148 | 149 | sink.create() |
149 | 150 | self.to_delete.append(sink) |
150 | 151 | self.assertTrue(sink.exists()) |
| 152 | + |
| 153 | + def test_create_sink_bigquery_dataset(self): |
| 154 | + from gcloud import bigquery |
| 155 | + from gcloud.bigquery.dataset import AccessGrant |
| 156 | + DATASET_URI = 'bigquery.googleapis.com/projects/%s/datasets/%s' % ( |
| 157 | + Config.CLIENT.project, DATASET_NAME,) |
| 158 | + |
| 159 | + # Create the destination dataset, and set up the ACL to allow |
| 160 | + # Cloud Logging to write into it. |
| 161 | + bigquery_client = bigquery.Client() |
| 162 | + dataset = bigquery_client.dataset(DATASET_NAME) |
| 163 | + dataset.create() |
| 164 | + self.to_delete.append(dataset) |
| 165 | + dataset.reload() |
| 166 | + grants = dataset.access_grants |
| 167 | + grants.append(AccessGrant( |
| 168 | + 'WRITER', 'groupByEmail', '[email protected]')) |
| 169 | + dataset.access_grants = grants |
| 170 | + dataset.update() |
| 171 | + |
| 172 | + sink = Config.CLIENT.sink( |
| 173 | + DEFAULT_SINK_NAME, DEFAULT_FILTER, DATASET_URI) |
| 174 | + self.assertFalse(sink.exists()) |
| 175 | + sink.create() |
| 176 | + self.to_delete.append(sink) |
| 177 | + self.assertTrue(sink.exists()) |
0 commit comments