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

Unified Diff: gslib/tests/test_mv.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gslib/tests/test_mb.py ('k') | gslib/tests/test_naming.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gslib/tests/test_mv.py
===================================================================
--- gslib/tests/test_mv.py (revision 33376)
+++ gslib/tests/test_mv.py (working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,9 +12,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Integration tests for mv command."""
+from __future__ import absolute_import
+
import gslib.tests.testcase as testcase
-from gslib.util import Retry
from gslib.tests.util import ObjectToURI as suri
@@ -21,21 +24,11 @@
"""Integration tests for mv command."""
def test_moving(self):
- # Create two buckets, one with 2 objects and one with 0 objects, and verify.
+ """Tests moving two buckets, one with 2 objects and one with 0 objects."""
bucket1_uri = self.CreateBucket(test_objects=2)
- # Use @Retry as hedge against bucket listing eventual consistency.
- @Retry(AssertionError, tries=3, timeout_secs=1)
- def _Check1():
- stdout = self.RunGsUtil(['ls', suri(bucket1_uri)], return_stdout=True)
- self.assertNumLines(stdout, 2)
- _Check1()
+ self.AssertNObjectsInBucket(bucket1_uri, 2)
bucket2_uri = self.CreateBucket()
- # Use @Retry as hedge against bucket listing eventual consistency.
- @Retry(AssertionError, tries=3, timeout_secs=1)
- def _Check2():
- stdout = self.RunGsUtil(['ls', suri(bucket2_uri)], return_stdout=True)
- self.assertNumLines(stdout, 0)
- _Check2()
+ self.AssertNObjectsInBucket(bucket2_uri, 0)
# Move two objects from bucket1 to bucket2.
objs = [bucket1_uri.clone_replace_key(key).versionless_uri
@@ -45,15 +38,8 @@
self.assertEqual(stderr.count('Copying'), 2)
self.assertEqual(stderr.count('Removing'), 2)
- # Verify objects were moved.
- # Use @Retry as hedge against bucket listing eventual consistency.
- @Retry(AssertionError, tries=3, timeout_secs=1)
- def _Check3():
- stdout = self.RunGsUtil(['ls', suri(bucket1_uri)], return_stdout=True)
- self.assertNumLines(stdout, 0)
- stdout = self.RunGsUtil(['ls', suri(bucket2_uri)], return_stdout=True)
- self.assertNumLines(stdout, 2)
- _Check3()
+ self.AssertNObjectsInBucket(bucket1_uri, 0)
+ self.AssertNObjectsInBucket(bucket2_uri, 2)
# Remove one of the objects.
objs = [bucket2_uri.clone_replace_key(key).versionless_uri
@@ -61,15 +47,8 @@
obj1 = objs[0]
self.RunGsUtil(['rm', obj1])
- # Verify there are now 1 and 0 objects.
- # Use @Retry as hedge against bucket listing eventual consistency.
- @Retry(AssertionError, tries=3, timeout_secs=1)
- def _Check4():
- stdout = self.RunGsUtil(['ls', suri(bucket1_uri)], return_stdout=True)
- self.assertNumLines(stdout, 0)
- stdout = self.RunGsUtil(['ls', suri(bucket2_uri)], return_stdout=True)
- self.assertNumLines(stdout, 1)
- _Check4()
+ self.AssertNObjectsInBucket(bucket1_uri, 0)
+ self.AssertNObjectsInBucket(bucket2_uri, 1)
# Move the 1 remaining object back.
objs = [suri(bucket2_uri.clone_replace_key(key))
@@ -79,12 +58,15 @@
self.assertEqual(stderr.count('Copying'), 1)
self.assertEqual(stderr.count('Removing'), 1)
- # Verify object moved.
- # Use @Retry as hedge against bucket listing eventual consistency.
- @Retry(AssertionError, tries=3, timeout_secs=1)
- def _Check5():
- stdout = self.RunGsUtil(['ls', suri(bucket1_uri)], return_stdout=True)
- self.assertNumLines(stdout, 1)
- stdout = self.RunGsUtil(['ls', suri(bucket2_uri)], return_stdout=True)
- self.assertNumLines(stdout, 0)
- _Check5()
+ self.AssertNObjectsInBucket(bucket1_uri, 1)
+ self.AssertNObjectsInBucket(bucket2_uri, 0)
+
+ def test_move_dir_to_bucket(self):
+ """Tests moving a local directory to a bucket."""
+ bucket_uri = self.CreateBucket()
+ dir_to_move = self.CreateTempDir(test_files=2)
+ self.RunGsUtil(['mv', dir_to_move, suri(bucket_uri)])
+ self.AssertNObjectsInBucket(bucket_uri, 2)
+
+
+
« no previous file with comments | « gslib/tests/test_mb.py ('k') | gslib/tests/test_naming.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698