| Index: gslib/tests/test_update.py
|
| ===================================================================
|
| --- gslib/tests/test_update.py (revision 33376)
|
| +++ gslib/tests/test_update.py (working copy)
|
| @@ -1,3 +1,4 @@
|
| +# -*- coding: utf-8 -*-
|
| # Copyright 2013 Google Inc. All Rights Reserved.
|
| #
|
| # Permission is hereby granted, free of charge, to any person obtaining a
|
| @@ -18,9 +19,10 @@
|
| # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
| # IN THE SOFTWARE.
|
| -
|
| """Tests for the update command."""
|
|
|
| +from __future__ import absolute_import
|
| +
|
| import os.path
|
| import shutil
|
| import subprocess
|
| @@ -31,7 +33,7 @@
|
| import gslib.tests.testcase as testcase
|
| from gslib.tests.util import ObjectToURI as suri
|
| from gslib.tests.util import unittest
|
| -from gslib.util import BOTO_IS_SECURE
|
| +from gslib.util import CERTIFICATE_VALIDATION_ENABLED
|
|
|
|
|
| TESTS_DIR = os.path.abspath(os.path.dirname(__file__))
|
| @@ -41,10 +43,10 @@
|
| class UpdateTest(testcase.GsUtilIntegrationTestCase):
|
| """Update command test suite."""
|
|
|
| - @unittest.skipUnless(BOTO_IS_SECURE[0],
|
| - 'Test requires boto secure connection.')
|
| + @unittest.skipUnless(CERTIFICATE_VALIDATION_ENABLED,
|
| + 'Test requires https certificate validation enabled.')
|
| def test_update(self):
|
| - """Tests that the update command works or throws proper exceptions."""
|
| + """Tests that the update command works or raises proper exceptions."""
|
|
|
| if gslib.IS_PACKAGE_INSTALL:
|
| # The update command is not present when installed via package manager.
|
| @@ -60,14 +62,17 @@
|
| # Copy gsutil to both source and destination directories.
|
| gsutil_src = os.path.join(tmpdir_src, 'gsutil')
|
| gsutil_dst = os.path.join(tmpdir_dst, 'gsutil')
|
| + # Path when executing from tmpdir (Windows doesn't support in-place rename)
|
| + gsutil_relative_dst = os.path.join('gsutil', 'gsutil')
|
| +
|
| shutil.copytree(GSUTIL_DIR, gsutil_src)
|
| # Copy specific files rather than all of GSUTIL_DIR so we don't pick up temp
|
| # working files left in top-level directory by gsutil developers (like tags,
|
| # .git*, etc.)
|
| os.makedirs(gsutil_dst)
|
| for comp in ('CHANGES.md', 'CHECKSUM', 'COPYING', 'gslib', 'gsutil',
|
| - 'gsutil.py', 'LICENSE.third_party', 'MANIFEST.in', 'README.md',
|
| - 'scripts', 'setup.py', 'third_party', 'VERSION'):
|
| + 'gsutil.py', 'MANIFEST.in', 'README.md', 'setup.py',
|
| + 'third_party', 'VERSION'):
|
| if os.path.isdir(os.path.join(GSUTIL_DIR, comp)):
|
| func = shutil.copytree
|
| else:
|
| @@ -113,7 +118,7 @@
|
| cwd=gsutil_dst, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| (_, stderr) = p.communicate()
|
| self.assertEqual(p.returncode, 1)
|
| - self.assertIn('non-existent object', stderr)
|
| + self.assertIn('NotFoundException', stderr)
|
|
|
| # Run with file:// URI wihout -f option.
|
| p = subprocess.Popen(prefix + ['gsutil', 'update', suri(src_tarball)],
|
| @@ -136,11 +141,12 @@
|
| self.assertEqual(p.returncode, 1)
|
| self.assertIn(
|
| 'The update command cannot run with user data in the gsutil directory',
|
| - stderr.replace('\n', ' '))
|
| + stderr.replace(os.linesep, ' '))
|
|
|
| # Now do the real update, which should succeed.
|
| - p = subprocess.Popen(prefix + ['gsutil', 'update', '-f', suri(src_tarball)],
|
| - cwd=gsutil_dst, stdout=subprocess.PIPE,
|
| + p = subprocess.Popen(prefix + [gsutil_relative_dst, 'update', '-f',
|
| + suri(src_tarball)],
|
| + cwd=tmpdir_dst, stdout=subprocess.PIPE,
|
| stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
| (_, stderr) = p.communicate(input='y\r\n')
|
| self.assertEqual(p.returncode, 0, msg=(
|
|
|