summaryrefslogtreecommitdiff
path: root/tests/unit/test_swiftclient.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/test_swiftclient.py')
-rw-r--r--tests/unit/test_swiftclient.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index ae46099..1cfe204 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -75,6 +75,7 @@ class MockHttpResponse(object):
self.headers = {'etag': '"%s"' % EMPTY_ETAG}
if headers:
self.headers.update(headers)
+ self.closed = False
class Raw(object):
def __init__(self, headers):
@@ -92,7 +93,7 @@ class MockHttpResponse(object):
return ""
def close(self):
- pass
+ self.closed = True
def getheader(self, name, default):
return self.headers.get(name, default)
@@ -1145,6 +1146,17 @@ class TestHTTPConnection(MockHttpTest):
conn = c.http_connection(u'http://www.test.com/', insecure=True)
self.assertEqual(conn[1].requests_args['verify'], False)
+ def test_response_connection_released(self):
+ _parsed_url, conn = c.http_connection(u'http://www.test.com/')
+ conn.resp = MockHttpResponse()
+ conn.resp.raw = mock.Mock()
+ conn.resp.raw.read.side_effect = ["Chunk", ""]
+ resp = conn.getresponse()
+ self.assertFalse(resp.closed)
+ self.assertEqual("Chunk", resp.read())
+ self.assertFalse(resp.read())
+ self.assertTrue(resp.closed)
+
class TestConnection(MockHttpTest):