From 4dd8f6785d74abc8e5760033d35cfb7550e7f6b5 Mon Sep 17 00:00:00 2001 From: Ali Afshar Date: Mon, 19 May 2014 14:12:32 -0700 Subject: [PATCH] Don't assume that httplib2 responses contain any preset attributes, since they are looked up dynamically from a response headers dict. Fixes #93 --- gcloud/storage/exceptions.py | 2 +- gcloud/storage/test_connection.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcloud/storage/exceptions.py b/gcloud/storage/exceptions.py index 1d23a96cfdb8..dff01204bc95 100644 --- a/gcloud/storage/exceptions.py +++ b/gcloud/storage/exceptions.py @@ -14,7 +14,7 @@ def __init__(self, response, content): class NotFoundError(ConnectionError): def __init__(self, response, content): - self.message = 'GET %s returned a 404.' % (response.url) + self.message = 'Request returned a 404. Headers: %s' % (response) class StorageDataError(StorageError): diff --git a/gcloud/storage/test_connection.py b/gcloud/storage/test_connection.py index 0a6923d9b27e..cfb4ff60a6a9 100644 --- a/gcloud/storage/test_connection.py +++ b/gcloud/storage/test_connection.py @@ -1,10 +1,19 @@ import unittest2 from gcloud.storage.connection import Connection - +from gcloud.storage.exceptions import NotFoundError class TestConnection(unittest2.TestCase): def test_init(self): connection = Connection('project-name') self.assertEqual('project-name', connection.project) + + +class TestExceptions(unittest2.TestCase): + + def test_not_found_always_prints(self): + e = NotFoundError({}, None) + self.assertEqual('', str(e)) + +