summaryrefslogtreecommitdiff
path: root/tests/test_swiftclient.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_swiftclient.py')
-rw-r--r--tests/test_swiftclient.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py
index 1c6d3e9..2387038 100644
--- a/tests/test_swiftclient.py
+++ b/tests/test_swiftclient.py
@@ -918,5 +918,30 @@ class TestLogging(MockHttpTest):
http_conn=conn, headers=headers)
+class TestCloseConnection(MockHttpTest):
+
+ def test_close_none(self):
+ c.http_connection = self.fake_http_connection(200)
+ conn = c.Connection('http://www.test.com', 'asdf', 'asdf')
+ self.assertEqual(conn.http_conn, None)
+ conn.close()
+ self.assertEqual(conn.http_conn, None)
+
+ def test_close_ok(self):
+ url = 'http://www.test.com'
+ c.http_connection = self.fake_http_connection(200)
+ conn = c.Connection(url, 'asdf', 'asdf')
+ self.assertEqual(conn.http_conn, None)
+
+ conn.http_conn = c.http_connection(url)
+ self.assertEqual(type(conn.http_conn), tuple)
+ self.assertEqual(len(conn.http_conn), 2)
+ http_conn_obj = conn.http_conn[1]
+ self.assertEqual(http_conn_obj.isclosed(), False)
+ conn.close()
+ self.assertEqual(http_conn_obj.isclosed(), True)
+ self.assertEqual(conn.http_conn, None)
+
+
if __name__ == '__main__':
testtools.main()