diff options
author | Feng Liu <mefengliu23@gmail.com> | 2013-10-17 11:12:06 +0800 |
---|---|---|
committer | Feng Liu <mefengliu23@gmail.com> | 2013-10-23 11:31:10 +0800 |
commit | 9fe79a4aacfd47be6a1d92097c1d84ccd6763073 (patch) | |
tree | c7be028884d96268c537456b2d3aaf6dd7ab6813 /tests/test_swiftclient.py | |
parent | 775a24b1bcb580216754e56b5384f05815372791 (diff) | |
download | python-swiftclient-9fe79a4aacfd47be6a1d92097c1d84ccd6763073.tar.gz |
Add close to swiftclient.client.Connection
Change-Id: I2f5fa9c46886607a9ba99e8915ea84ac4975d004
Diffstat (limited to 'tests/test_swiftclient.py')
-rw-r--r-- | tests/test_swiftclient.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index e827a2a..9fc13a2 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -938,5 +938,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() |