Skip to content

Commit

Permalink
Merge pull request #1681 from tseaver/logging-system_tests-sink_update
Browse files Browse the repository at this point in the history
Add system test for 'Sink.update'.
  • Loading branch information
tseaver committed Mar 30, 2016
2 parents ae88612 + a0c2d89 commit 7ae4fd5
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions system_tests/logging_.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_update_metric(self):
self.assertEqual(after.filter_, NEW_FILTER)
self.assertEqual(after.description, NEW_DESCRIPTION)

def test_create_sink_storage_bucket(self):
def _init_storage_bucket(self):
from gcloud import storage
BUCKET_URI = 'storage.googleapis.com/%s' % (BUCKET_NAME,)

Expand All @@ -147,8 +147,12 @@ def test_create_sink_storage_bucket(self):
bucket.acl.add_entity(logs_group)
bucket.acl.save()

sink = Config.CLIENT.sink(
DEFAULT_SINK_NAME, DEFAULT_FILTER, BUCKET_URI)
return BUCKET_URI

def test_create_sink_storage_bucket(self):
uri = self._init_storage_bucket()

sink = Config.CLIENT.sink(DEFAULT_SINK_NAME, DEFAULT_FILTER, uri)
self.assertFalse(sink.exists())
sink.create()
self.to_delete.append(sink)
Expand Down Expand Up @@ -193,3 +197,18 @@ def test_reload_sink(self):
sink.reload()
self.assertEqual(sink.filter_, DEFAULT_FILTER)
self.assertEqual(sink.destination, uri)

def test_update_sink(self):
bucket_uri = self._init_storage_bucket()
dataset_uri = self._init_bigquery_dataset()
UPDATED_FILTER = 'logName:syslog'
sink = Config.CLIENT.sink(
DEFAULT_SINK_NAME, DEFAULT_FILTER, bucket_uri)
self.assertFalse(sink.exists())
sink.create()
self.to_delete.append(sink)
sink.filter_ = UPDATED_FILTER
sink.destination = dataset_uri
sink.update()
self.assertEqual(sink.filter_, UPDATED_FILTER)
self.assertEqual(sink.destination, dataset_uri)

0 comments on commit 7ae4fd5

Please sign in to comment.