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

Side by Side Diff: gslib/tests/test_versioning.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_util.py ('k') | gslib/tests/test_web.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 versioning command."""
16
17 from __future__ import absolute_import
14 18
15 import gslib.tests.testcase as testcase 19 import gslib.tests.testcase as testcase
16 from gslib.tests.util import ObjectToURI as suri 20 from gslib.tests.util import ObjectToURI as suri
21 from gslib.util import Retry
17 22
18 23
19 class TestVersioning(testcase.GsUtilIntegrationTestCase): 24 class TestVersioning(testcase.GsUtilIntegrationTestCase):
20 """Integration tests for versioning command.""" 25 """Integration tests for versioning command."""
21 26
22 _set_cmd_prefix = ['versioning', 'set'] 27 _set_ver_cmd = ['versioning', 'set']
23 _get_cmd_prefix = ['versioning', 'get'] 28 _get_ver_cmd = ['versioning', 'get']
24 29
25 def test_off_default(self): 30 def test_off_default(self):
26 bucket_uri = self.CreateBucket() 31 bucket_uri = self.CreateBucket()
27 stdout = self.RunGsUtil( 32 stdout = self.RunGsUtil(
28 self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True) 33 self._get_ver_cmd + [suri(bucket_uri)], return_stdout=True)
29 self.assertEqual(stdout.strip(), '%s: Suspended' % suri(bucket_uri)) 34 self.assertEqual(stdout.strip(), '%s: Suspended' % suri(bucket_uri))
30 35
31 def test_turning_on(self): 36 def test_turning_on(self):
32 bucket_uri = self.CreateBucket() 37 bucket_uri = self.CreateBucket()
33 self.RunGsUtil(self._set_cmd_prefix + ['on', suri(bucket_uri)]) 38 self.RunGsUtil(self._set_ver_cmd + ['on', suri(bucket_uri)])
34 stdout = self.RunGsUtil( 39
35 self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True) 40 # Work around eventual consistency for S3 versioning.
36 self.assertEqual(stdout.strip(), '%s: Enabled' % suri(bucket_uri)) 41 @Retry(AssertionError, tries=3, timeout_secs=1)
42 def _Check1():
43 stdout = self.RunGsUtil(
44 self._get_ver_cmd + [suri(bucket_uri)], return_stdout=True)
45 self.assertEqual(stdout.strip(), '%s: Enabled' % suri(bucket_uri))
46 _Check1()
37 47
38 def test_turning_off(self): 48 def test_turning_off(self):
39 bucket_uri = self.CreateBucket() 49 bucket_uri = self.CreateBucket()
40 self.RunGsUtil(self._set_cmd_prefix + ['on', suri(bucket_uri)]) 50 self.RunGsUtil(self._set_ver_cmd + ['on', suri(bucket_uri)])
41 stdout = self.RunGsUtil( 51
42 self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True) 52 # Work around eventual consistency for S3 versioning.
43 self.assertEqual(stdout.strip(), '%s: Enabled' % suri(bucket_uri)) 53 @Retry(AssertionError, tries=3, timeout_secs=1)
44 self.RunGsUtil(self._set_cmd_prefix + ['off', suri(bucket_uri)]) 54 def _Check1():
45 stdout = self.RunGsUtil( 55 stdout = self.RunGsUtil(
46 self._get_cmd_prefix + [suri(bucket_uri)], return_stdout=True) 56 self._get_ver_cmd + [suri(bucket_uri)], return_stdout=True)
47 self.assertEqual(stdout.strip(), '%s: Suspended' % suri(bucket_uri)) 57 self.assertEqual(stdout.strip(), '%s: Enabled' % suri(bucket_uri))
58 _Check1()
59
60 self.RunGsUtil(self._set_ver_cmd + ['off', suri(bucket_uri)])
61
62 # Work around eventual consistency for S3 versioning.
63 @Retry(AssertionError, tries=3, timeout_secs=1)
64 def _Check2():
65 stdout = self.RunGsUtil(
66 self._get_ver_cmd + [suri(bucket_uri)], return_stdout=True)
67 self.assertEqual(stdout.strip(), '%s: Suspended' % suri(bucket_uri))
68 _Check2()
48 69
49 def testTooFewArgumentsFails(self): 70 def testTooFewArgumentsFails(self):
71 """Ensures versioning commands fail with too few arguments."""
50 # No arguments for set, but valid subcommand. 72 # No arguments for set, but valid subcommand.
51 stderr = self.RunGsUtil(self._set_cmd_prefix, return_stderr=True, 73 stderr = self.RunGsUtil(self._set_ver_cmd, return_stderr=True,
52 expected_status=1) 74 expected_status=1)
53 self.assertIn('command requires at least', stderr) 75 self.assertIn('command requires at least', stderr)
54 76
55 # No arguments for get, but valid subcommand. 77 # No arguments for get, but valid subcommand.
56 stderr = self.RunGsUtil(self._get_cmd_prefix, return_stderr=True, 78 stderr = self.RunGsUtil(self._get_ver_cmd, return_stderr=True,
57 expected_status=1) 79 expected_status=1)
58 self.assertIn('command requires at least', stderr) 80 self.assertIn('command requires at least', stderr)
59 81
60 # Neither arguments nor subcommand. 82 # Neither arguments nor subcommand.
61 stderr = self.RunGsUtil(['versioning'], return_stderr=True, 83 stderr = self.RunGsUtil(['versioning'], return_stderr=True,
62 expected_status=1) 84 expected_status=1)
63 self.assertIn('command requires at least', stderr) 85 self.assertIn('command requires at least', stderr)
64 86
87
65 class TestVersioningOldAlias(TestVersioning): 88 class TestVersioningOldAlias(TestVersioning):
66 _set_cmd_prefix = ['setversioning'] 89 _set_ver_cmd = ['setversioning']
67 _get_cmd_prefix = ['getversioning'] 90 _get_ver_cmd = ['getversioning']
OLDNEW
« no previous file with comments | « gslib/tests/test_util.py ('k') | gslib/tests/test_web.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698