From 8fc7a0fba577ea60a8377c215b5c0142af79b8bb Mon Sep 17 00:00:00 2001
From: Itamar Turner-Trauring <itamar@futurefoundries.com>
Date: Tue, 5 Mar 2013 12:01:06 -0500
Subject: [PATCH] If oauth2client isn't present, skip Google Storage tests
 rather than blowing up.

---
 .../cloud/googlestorage/googlestorage_container.py         | 7 ++++++-
 src/allmydata/test/test_storage.py                         | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/allmydata/storage/backends/cloud/googlestorage/googlestorage_container.py b/src/allmydata/storage/backends/cloud/googlestorage/googlestorage_container.py
index af3a82a9..cf6f1537 100644
--- a/src/allmydata/storage/backends/cloud/googlestorage/googlestorage_container.py
+++ b/src/allmydata/storage/backends/cloud/googlestorage/googlestorage_container.py
@@ -18,7 +18,12 @@ from twisted.internet.defer import DeferredLock
 from twisted.internet.threads import deferToThread
 from twisted.web.http import UNAUTHORIZED
 
-from oauth2client.client import SignedJwtAssertionCredentials
+try:
+    from oauth2client.client import SignedJwtAssertionCredentials
+    oauth2client_available = True
+except ImportError:
+    oauth2client_available = False
+    SignedJwtAssertionCredentials = None
 
 from zope.interface import implements
 
diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py
index d2828f21..e7417da6 100644
--- a/src/allmydata/test/test_storage.py
+++ b/src/allmydata/test/test_storage.py
@@ -642,6 +642,9 @@ class GoogleStorageAuthenticationClient(unittest.TestCase):
     unless noted otherwise.
     """
 
+    if not googlestorage_container.oauth2client_available:
+        skip = "Google Storage requires oauth2client"
+
     def test_credentials(self):
         """
         AuthenticationClient.get_authorization_header() initializes a
@@ -766,6 +769,9 @@ class GoogleStorageBackend(unittest.TestCase):
     allmydata.storage.backends.cloud.googlestorage.googlestorage_container
     unless noted otherwise.
     """
+    if not googlestorage_container.oauth2client_available:
+        skip = "Google Storage requires oauth2client"
+
     class Response(object):
         def __init__(self, code, headers={}):
             self.code = code
-- 
2.45.2