Skip to content

Commit 20e3d7b

Browse files
authored
bigquery: add system test for dataset update with etag (#4052)
1 parent 08141bd commit 20e3d7b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bigquery/tests/system.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import six
2626

27+
from google.api.core.exceptions import PreconditionFailed
2728
from google.cloud import bigquery
2829
from google.cloud.bigquery.dataset import Dataset, DatasetReference
2930
from google.cloud.bigquery.table import Table
@@ -158,7 +159,11 @@ def test_update_dataset(self):
158159
ds3 = Config.CLIENT.update_dataset(ds2, ['labels'])
159160
self.assertEqual(ds3.labels, {'color': 'green', 'shape': 'circle'})
160161

161-
# TODO(jba): test that read-modify-write with ETag works.
162+
# If we try to update using d2 again, it will fail because the
163+
# previous update changed the ETag.
164+
ds2.description = 'no good'
165+
with self.assertRaises(PreconditionFailed):
166+
Config.CLIENT.update_dataset(ds2, ['description'])
162167

163168
def test_list_datasets(self):
164169
datasets_to_create = [

0 commit comments

Comments
 (0)