Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Side by Side Diff: gslib/tests/test_notification.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gslib/tests/test_naming.py ('k') | gslib/tests/test_oauth2_client.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8 -*-
1 # Copyright 2013 Google Inc. All Rights Reserved. 2 # Copyright 2013 Google Inc. All Rights Reserved.
2 # 3 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
6 # 7 #
7 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
8 # 9 #
9 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and 13 # See the License for the specific language governing permissions and
13 # limitations under the License. 14 # limitations under the License.
15 """Integration tests for notification command."""
16
17 from __future__ import absolute_import
14 18
15 import re 19 import re
16 import uuid 20 import uuid
17 21
18 import boto 22 import boto
19 23
20 import gslib.tests.testcase as testcase 24 import gslib.tests.testcase as testcase
21 from gslib.tests.util import ObjectToURI as suri 25 from gslib.tests.util import ObjectToURI as suri
22 from gslib.tests.util import unittest 26 from gslib.tests.util import unittest
23 27
24 28
25 def _LoadNotificationUrl(): 29 def _LoadNotificationUrl():
26 return boto.config.get_value('GSUtil', 'test_notification_url') 30 return boto.config.get_value('GSUtil', 'test_notification_url')
27 31
28 NOTIFICATION_URL = _LoadNotificationUrl() 32 NOTIFICATION_URL = _LoadNotificationUrl()
29 33
30 34
31 class TestNotification(testcase.GsUtilIntegrationTestCase): 35 class TestNotification(testcase.GsUtilIntegrationTestCase):
32 """Integration tests for notification command.""" 36 """Integration tests for notification command."""
33 37
34 @unittest.skipUnless(NOTIFICATION_URL, 38 @unittest.skipUnless(NOTIFICATION_URL,
35 'Test requires notification URL configuration.') 39 'Test requires notification URL configuration.')
36 def test_watch_bucket(self): 40 def test_watch_bucket(self):
41 """Tests creating a notification channel on a bucket."""
37 bucket_uri = self.CreateBucket() 42 bucket_uri = self.CreateBucket()
38 self.RunGsUtil([ 43 self.RunGsUtil([
39 'notification', 'watchbucket', NOTIFICATION_URL, suri(bucket_uri)]) 44 'notification', 'watchbucket', NOTIFICATION_URL, suri(bucket_uri)])
40 45
41 identifier = str(uuid.uuid4()) 46 identifier = str(uuid.uuid4())
42 token = str(uuid.uuid4()) 47 token = str(uuid.uuid4())
43 stderr = self.RunGsUtil([ 48 stderr = self.RunGsUtil([
44 'notification', 'watchbucket', '-i', identifier, '-t', token, 49 'notification', 'watchbucket', '-i', identifier, '-t', token,
45 NOTIFICATION_URL, suri(bucket_uri)], return_stderr=True) 50 NOTIFICATION_URL, suri(bucket_uri)], return_stderr=True)
46 self.assertIn('token: %s' % token, stderr) 51 self.assertIn('token: %s' % token, stderr)
47 self.assertIn('identifier: %s' % identifier, stderr) 52 self.assertIn('identifier: %s' % identifier, stderr)
48 53
49 @unittest.skipUnless(NOTIFICATION_URL, 54 @unittest.skipUnless(NOTIFICATION_URL,
50 'Test requires notification URL configuration.') 55 'Test requires notification URL configuration.')
51 def test_stop_channel(self): 56 def test_stop_channel(self):
57 """Tests stopping a notification channel on a bucket."""
52 bucket_uri = self.CreateBucket() 58 bucket_uri = self.CreateBucket()
53 stderr = self.RunGsUtil( 59 stderr = self.RunGsUtil(
54 ['notification', 'watchbucket', NOTIFICATION_URL, suri(bucket_uri)], 60 ['notification', 'watchbucket', NOTIFICATION_URL, suri(bucket_uri)],
55 return_stderr=True) 61 return_stderr=True)
56 62
57 channel_id = re.findall(r'channel identifier: (?P<id>.*)', stderr) 63 channel_id = re.findall(r'channel identifier: (?P<id>.*)', stderr)
58 self.assertEqual(len(channel_id), 1) 64 self.assertEqual(len(channel_id), 1)
59 resource_id = re.findall(r'resource identifier: (?P<id>.*)', stderr) 65 resource_id = re.findall(r'resource identifier: (?P<id>.*)', stderr)
60 self.assertEqual(len(resource_id), 1) 66 self.assertEqual(len(resource_id), 1)
61 67
62 channel_id = channel_id[0] 68 channel_id = channel_id[0]
63 resource_id = resource_id[0] 69 resource_id = resource_id[0]
64 70
65 self.RunGsUtil(['notification', 'stopchannel', channel_id, resource_id]) 71 self.RunGsUtil(['notification', 'stopchannel', channel_id, resource_id])
66 72
67 def test_invalid_subcommand(self): 73 def test_invalid_subcommand(self):
68 stderr = self.RunGsUtil(['notification', 'foo', 'bar', 'baz'], 74 stderr = self.RunGsUtil(['notification', 'foo', 'bar', 'baz'],
69 return_stderr=True, expected_status=1) 75 return_stderr=True, expected_status=1)
70 self.assertIn('Invalid subcommand', stderr) 76 self.assertIn('Invalid subcommand', stderr)
OLDNEW
« no previous file with comments | « gslib/tests/test_naming.py ('k') | gslib/tests/test_oauth2_client.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698