OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # Copyright 2013 Google Inc. All Rights Reserved. | 2 # Copyright 2013 Google Inc. All Rights Reserved. |
3 # | 3 # |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
5 # 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. |
6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
7 # | 7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # | 9 # |
10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 expected_status=1) | 428 expected_status=1) |
429 self.assertRegexpMatches( | 429 self.assertRegexpMatches( |
430 stderr, r'PreconditionException: 412 Precondition\s*Failed') | 430 stderr, r'PreconditionException: 412 Precondition\s*Failed') |
431 | 431 |
432 def test_stdin_args(self): | 432 def test_stdin_args(self): |
433 """Tests rm with the -I option.""" | 433 """Tests rm with the -I option.""" |
434 buri1 = self.CreateVersionedBucket() | 434 buri1 = self.CreateVersionedBucket() |
435 ouri1 = self.CreateObject(bucket_uri=buri1, | 435 ouri1 = self.CreateObject(bucket_uri=buri1, |
436 object_name='foo', | 436 object_name='foo', |
437 contents='foocontents') | 437 contents='foocontents') |
438 ouri2 = self.CreateObject(bucket_uri=buri1, | 438 self.CreateObject(bucket_uri=buri1, object_name='bar', |
439 object_name='bar', | 439 contents='barcontents') |
440 contents='barcontents') | |
441 ouri3 = self.CreateObject(bucket_uri=buri1, | 440 ouri3 = self.CreateObject(bucket_uri=buri1, |
442 object_name='baz', | 441 object_name='baz', |
443 contents='bazcontents') | 442 contents='bazcontents') |
444 buri2 = self.CreateVersionedBucket() | 443 buri2 = self.CreateVersionedBucket() |
445 ouri4 = self.CreateObject(bucket_uri=buri2, | 444 ouri4 = self.CreateObject(bucket_uri=buri2, |
446 object_name='moo', | 445 object_name='moo', |
447 contents='moocontents') | 446 contents='moocontents') |
448 self.AssertNObjectsInBucket(buri1, 3, versioned=True) | 447 self.AssertNObjectsInBucket(buri1, 3, versioned=True) |
449 self.AssertNObjectsInBucket(buri2, 1, versioned=True) | 448 self.AssertNObjectsInBucket(buri2, 1, versioned=True) |
450 | 449 |
451 objects_to_remove = ['%s#%s' % (suri(ouri1), urigen(ouri1)), | 450 objects_to_remove = ['%s#%s' % (suri(ouri1), urigen(ouri1)), |
452 '%s#%s' % (suri(ouri3), urigen(ouri3)), | 451 '%s#%s' % (suri(ouri3), urigen(ouri3)), |
453 '%s#%s' % (suri(ouri4), urigen(ouri4))] | 452 '%s#%s' % (suri(ouri4), urigen(ouri4))] |
454 stdin = '\n'.join(objects_to_remove) | 453 stdin = '\n'.join(objects_to_remove) |
455 self._RunRemoveCommandAndCheck(['rm', '-I'], | 454 self._RunRemoveCommandAndCheck(['rm', '-I'], |
456 objects_to_remove=objects_to_remove, | 455 objects_to_remove=objects_to_remove, |
457 stdin=stdin) | 456 stdin=stdin) |
458 self.AssertNObjectsInBucket(buri1, 1, versioned=True) | 457 self.AssertNObjectsInBucket(buri1, 1, versioned=True) |
459 self.AssertNObjectsInBucket(buri2, 0, versioned=True) | 458 self.AssertNObjectsInBucket(buri2, 0, versioned=True) |
| 459 |
| 460 def test_rm_nonexistent_bucket_recursive(self): |
| 461 stderr = self.RunGsUtil( |
| 462 ['rm', '-rf', '%s://%s' % (self.default_provider, |
| 463 self.nonexistent_bucket_name)], |
| 464 return_stderr=True, expected_status=1) |
| 465 self.assertIn('Encountered non-existent bucket', stderr) |
| 466 |
| 467 def test_rm_multiple_nonexistent_objects(self): |
| 468 bucket_uri = self.CreateBucket() |
| 469 nonexistent_object1 = suri(bucket_uri, 'nonexistent1') |
| 470 nonexistent_object2 = suri(bucket_uri, 'nonexistent1') |
| 471 stderr = self.RunGsUtil( |
| 472 ['rm', '-rf', nonexistent_object1, nonexistent_object2], |
| 473 return_stderr=True, expected_status=1) |
| 474 self.assertIn('2 files/objects could not be removed.', stderr) |
OLD | NEW |