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

Side by Side Diff: third_party/gsutil/gslib/tests/test_ls.py

Issue 12317103: Added gsutil to depot tools (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: added readme Created 7 years, 9 months 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
OLDNEW
(Empty)
1 # Copyright 2013 Google Inc. All Rights Reserved.
2 #
3 # 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 obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import gslib.tests.testcase as testcase
16 from gslib.util import Retry
17 from gslib.tests.util import ObjectToURI as suri
18
19
20 class TestLs(testcase.GsUtilIntegrationTestCase):
21 """Integration tests for ls command."""
22
23 def test_blank_ls(self):
24 self.RunGsUtil(['ls'])
25
26 def test_empty_bucket(self):
27 bucket_uri = self.CreateBucket()
28 # Use @Retry as hedge against bucket listing eventual consistency.
29 @Retry(AssertionError, tries=3, delay=1, backoff=1)
30 def _Check1():
31 stdout = self.RunGsUtil(['ls', suri(bucket_uri)], return_stdout=True)
32 self.assertEqual('', stdout)
33 _Check1()
34
35 def test_empty_bucket_with_b(self):
36 bucket_uri = self.CreateBucket()
37 # Use @Retry as hedge against bucket listing eventual consistency.
38 @Retry(AssertionError, tries=3, delay=1, backoff=1)
39 def _Check1():
40 stdout = self.RunGsUtil(['ls', '-b', suri(bucket_uri)],
41 return_stdout=True)
42 self.assertEqual('%s/\n' % suri(bucket_uri), stdout)
43 _Check1()
44
45 def test_with_one_object(self):
46 bucket_uri = self.CreateBucket(test_objects=1)
47 objuri = [suri(bucket_uri.clone_replace_name(key.name))
48 for key in bucket_uri.list_bucket()][0]
49 # Use @Retry as hedge against bucket listing eventual consistency.
50 @Retry(AssertionError, tries=3, delay=1, backoff=1)
51 def _Check1():
52 stdout = self.RunGsUtil(['ls', suri(bucket_uri)], return_stdout=True)
53 self.assertEqual('%s\n' % objuri, stdout)
54 _Check1()
55
56 def test_subdir(self):
57 bucket_uri = self.CreateBucket(test_objects=1)
58 k1_uri = bucket_uri.clone_replace_name('foo')
59 k1_uri.set_contents_from_string('baz')
60 k2_uri = bucket_uri.clone_replace_name('dir/foo')
61 k2_uri.set_contents_from_string('bar')
62 # Use @Retry as hedge against bucket listing eventual consistency.
63 @Retry(AssertionError, tries=3, delay=1, backoff=1)
64 def _Check1():
65 stdout = self.RunGsUtil(['ls', '%s/dir' % suri(bucket_uri)],
66 return_stdout=True)
67 self.assertEqual('%s\n' % suri(k2_uri), stdout)
68 stdout = self.RunGsUtil(['ls', suri(k1_uri)], return_stdout=True)
69 self.assertEqual('%s\n' % suri(k1_uri), stdout)
70 _Check1()
71
72 def test_versioning(self):
73 bucket1_uri = self.CreateBucket(test_objects=1)
74 bucket2_uri = self.CreateVersionedBucket(test_objects=1)
75 bucket_list = list(bucket1_uri.list_bucket())
76 objuri = [bucket1_uri.clone_replace_key(key).versionless_uri
77 for key in bucket_list][0]
78 self.RunGsUtil(['cp', objuri, suri(bucket2_uri)])
79 self.RunGsUtil(['cp', objuri, suri(bucket2_uri)])
80 # Use @Retry as hedge against bucket listing eventual consistency.
81 @Retry(AssertionError, tries=3, delay=1, backoff=1)
82 def _Check1():
83 stdout = self.RunGsUtil(['ls', '-a', suri(bucket2_uri)],
84 return_stdout=True)
85 self.assertNumLines(stdout, 3)
86 stdout = self.RunGsUtil(['ls', '-la', suri(bucket2_uri)],
87 return_stdout=True)
88 self.assertIn('%s#' % bucket2_uri.clone_replace_name(bucket_list[0].name),
89 stdout)
90 self.assertIn('meta_generation=', stdout)
91 _Check1()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698