From 7e88e395b44606ff14beb6461f417ac43acf82c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Ar=C8=9B=C4=83ri=C8=99i?= Date: Tue, 24 Jul 2012 11:33:53 +0200 Subject: [PATCH] use boto's HTTPResponse class for versions of boto >=2.5.2 Fixes bug: 1027984 Change-Id: I2101ddaa78ede90f39b55d28aab73e7f5a816af5 --- Authors | 1 + nova/tests/test_api.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Authors b/Authors index 591c4497a67..e99168a70ed 100644 --- a/Authors +++ b/Authors @@ -74,6 +74,7 @@ Hengqing Hu Hisaharu Ishii Hisaki Ohara Ilya Alekseyev +Ionuț Arțăriși Isaku Yamahata Ivan Kolodyazhny J. Daniel Schmidt diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index a52319f6204..4a04783f843 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -19,13 +19,17 @@ """Unit tests for the API endpoint""" import datetime -import httplib import random import StringIO import boto from boto.ec2 import regioninfo from boto import exception as boto_exc +# newer versions of boto use their own wrapper on top of httplib.HTTPResponse +try: + from boto.connection import HTTPResponse +except ImportError: + from httplib import HTTPResponse import webob from nova import block_device @@ -55,7 +59,7 @@ class FakeHttplibConnection(object): requests made via this connection actually get translated and routed into our WSGI app, we then wait for the response and turn it back into - the httplib.HTTPResponse that boto expects. + the HTTPResponse that boto expects. """ def __init__(self, app, host, is_secure=False): self.app = app @@ -74,7 +78,7 @@ def request(self, method, path, data, headers): # guess that's a function the web server usually provides. resp = "HTTP/1.0 %s" % resp self.sock = FakeHttplibSocket(resp) - self.http_response = httplib.HTTPResponse(self.sock) + self.http_response = HTTPResponse(self.sock) # NOTE(vish): boto is accessing private variables for some reason self._HTTPConnection__response = self.http_response self.http_response.begin()