OLD | NEW |
| (Empty) |
1 # -*- coding: utf-8 -*- | |
2 # Copyright 2014 Google Inc. All Rights Reserved. | |
3 # | |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | |
5 # you may not use this file except in compliance with the License. | |
6 # You may obtain a copy of the License at | |
7 # | |
8 # http://www.apache.org/licenses/LICENSE-2.0 | |
9 # | |
10 # Unless required by applicable law or agreed to in writing, software | |
11 # distributed under the License is distributed on an "AS IS" BASIS, | |
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 # See the License for the specific language governing permissions and | |
14 # limitations under the License. | |
15 """Integration tests for rb command.""" | |
16 | |
17 from __future__ import absolute_import | |
18 | |
19 import gslib.tests.testcase as testcase | |
20 from gslib.tests.util import ObjectToURI as suri | |
21 | |
22 | |
23 class TestRb(testcase.GsUtilIntegrationTestCase): | |
24 """Integration tests for rb command.""" | |
25 | |
26 def test_rb_bucket_works(self): | |
27 bucket_uri = self.CreateBucket() | |
28 self.RunGsUtil(['rb', suri(bucket_uri)]) | |
29 stderr = self.RunGsUtil( | |
30 ['ls', '-Lb', 'gs://%s' % self.nonexistent_bucket_name], | |
31 return_stderr=True, expected_status=1) | |
32 self.assertIn('404', stderr) | |
33 | |
34 def test_rb_bucket_not_empty(self): | |
35 bucket_uri = self.CreateBucket(test_objects=1) | |
36 stderr = self.RunGsUtil(['rb', suri(bucket_uri)], expected_status=1, | |
37 return_stderr=True) | |
38 self.assertIn('BucketNotEmpty', stderr) | |
39 | |
40 def test_rb_versioned_bucket_not_empty(self): | |
41 bucket_uri = self.CreateVersionedBucket(test_objects=1) | |
42 stderr = self.RunGsUtil(['rb', suri(bucket_uri)], expected_status=1, | |
43 return_stderr=True) | |
44 self.assertIn('Bucket is not empty. Note: this is a versioned bucket', | |
45 stderr) | |
46 | |
47 def test_rb_minus_f(self): | |
48 bucket_uri = self.CreateBucket() | |
49 stderr = self.RunGsUtil([ | |
50 'rb', '-f', 'gs://%s' % self.nonexistent_bucket_name, | |
51 suri(bucket_uri)], return_stderr=True, expected_status=1) | |
52 # There should be no error output, and existing bucket named after | |
53 # non-existent bucket should be gone. | |
54 self.assertNotIn('bucket does not exist.', stderr) | |
55 stderr = self.RunGsUtil( | |
56 ['ls', '-Lb', suri(bucket_uri)], return_stderr=True, expected_status=1) | |
57 self.assertIn('404', stderr) | |
OLD | NEW |