Skip to content

Commit

Permalink
Fix gsutil 3.34 unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marineam committed Aug 12, 2013
1 parent 185a3fc commit 426c2d2
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
2 changes: 2 additions & 0 deletions net-misc/gsutil/files/dummy.boto
Expand Up @@ -2,3 +2,5 @@

[Credentials]
gs_oauth2_refresh_token = 1/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

[GSUtil]
@@ -0,0 +1,30 @@
From 1b2eccc8a3c8c70855973d9dcff46bb0c4f79345 Mon Sep 17 00:00:00 2001
From: Michael Marineau <mike@marineau.org>
Date: Mon, 12 Aug 2013 17:42:39 -0400
Subject: [PATCH] Fix test using ? glob with ObjectToURI

Passing a ? wildcard through ObjectToURI does not work because passing
the constructed URI through urlparse.urlparse() interprets ? as a query
and strips it off since there is no query string following it. The *
glob which is actually used in the very next call doesn't have that
problem so just use that instead.
---
gslib/tests/test_naming.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gslib/tests/test_naming.py b/gslib/tests/test_naming.py
index b4d0ccd..8208238 100755
--- a/gslib/tests/test_naming.py
+++ b/gslib/tests/test_naming.py
@@ -840,7 +840,7 @@ class GsutilNamingTests(testcase.GsUtilUnitTestCase):
for i, final_dst_char in enumerate(('', '/')):
# Copy some files into place in dst bucket.
self.RunCommand(
- 'cp', [suri(src_bucket_uri, 'f%df?' % i),
+ 'cp', [suri(src_bucket_uri, 'f%df*' % i),
suri(dst_bucket_uri, 'dst_subdir%d' % i) + final_dst_char])
# Now do the move test.
self.RunCommand(
--
1.8.1.5

@@ -0,0 +1,45 @@
From a978811458f3d0c5379101bdda4396c62b8b0d6b Mon Sep 17 00:00:00 2001
From: Michael Marineau <mike@marineau.org>
Date: Mon, 12 Aug 2013 16:46:25 -0400
Subject: [PATCH] Fix update tests that fail for package installs.

Software updates are checked for but never offered in package installs.
Perhaps _MaybeCheckForAndOfferSoftwareUpdate should be split into two
functions so the "check for" and "offer" parts can be tested
independently but this fixes the tests as-is.
---
gslib/tests/test_command_runner.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gslib/tests/test_command_runner.py b/gslib/tests/test_command_runner.py
index 01b5312..0a9eb01 100644
--- a/gslib/tests/test_command_runner.py
+++ b/gslib/tests/test_command_runner.py
@@ -105,8 +105,10 @@ class TestSoftwareUpdateCheckUnitTests(
self._SetBotoConfig('GSUtil', 'software_update_check_period', '1')
with open(self.timestamp_file, 'w') as f:
f.write(str(int(time.time() - 2 * SECONDS_PER_DAY)))
+ # Update will not trigger for package installs.
+ expect = not gslib.IS_PACKAGE_INSTALL
self.assertEqual(
- True,
+ expect,
self.command_runner._MaybeCheckForAndOfferSoftwareUpdate('ls', 0))

def test_not_time_for_update_yet(self):
@@ -134,9 +136,10 @@ class TestSoftwareUpdateCheckUnitTests(
with open(self.timestamp_file, 'w') as f:
f.write(str(int(time.time() - 2 * SECONDS_PER_DAY)))

- # With regular loglevel, should return True.
+ # With regular loglevel, should return True except for package installs.
+ expect = not gslib.IS_PACKAGE_INSTALL
self.assertEqual(
- True,
+ expect,
self.command_runner._MaybeCheckForAndOfferSoftwareUpdate('ls', 0))

prev_loglevel = logging.getLogger().getEffectiveLevel()
--
1.8.1.5

8 changes: 6 additions & 2 deletions net-misc/gsutil/gsutil-3.34.ebuild
Expand Up @@ -30,9 +30,13 @@ RDEPEND="${DEPEND}

S=${WORKDIR}/${PN}
DOCS=( README.md CHANGES.md )
PATCHES=( ${FILESDIR}/${P}-use-friendy-version-checks.patch )
PATCHES=(
${FILESDIR}/${P}-use-friendy-version-checks.patch
${FILESDIR}/${P}-Fix-update-tests-that-fail-for-package-installs.patch
${FILESDIR}/${P}-Fix-test-using-glob-with-ObjectToURI.patch
)

python_test() {
export BOTO_CONFIG=${FILESDIR}/dummy.boto
${PYTHON} gslib/__main__.py test -u
${PYTHON} gslib/__main__.py test -u || die "tests failed"
}

0 comments on commit 426c2d2

Please sign in to comment.