You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2017/01/18 04:42:00 UTC
[1/3] libcloud git commit: create a test to prove LIBCLOUD-887 is a
bug
Repository: libcloud
Updated Branches:
refs/heads/trunk 0f831f561 -> 419c69441
create a test to prove LIBCLOUD-887 is a bug
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ed6d012a
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ed6d012a
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ed6d012a
Branch: refs/heads/trunk
Commit: ed6d012aab1c8bad83f66bf4ed4621b1d5fe0d27
Parents: 0f831f5
Author: Anthony Shaw <an...@apache.org>
Authored: Wed Jan 18 14:24:53 2017 +1100
Committer: Anthony Shaw <an...@apache.org>
Committed: Wed Jan 18 14:24:53 2017 +1100
----------------------------------------------------------------------
libcloud/test/test_logging_connection.py | 47 +++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ed6d012a/libcloud/test/test_logging_connection.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_logging_connection.py b/libcloud/test/test_logging_connection.py
new file mode 100644
index 0000000..3824838
--- /dev/null
+++ b/libcloud/test/test_logging_connection.py
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+from io import StringIO
+import requests_mock
+
+import libcloud
+from libcloud.test import unittest
+from libcloud.common.base import Connection
+from libcloud.utils.loggingconnection import LoggingConnection
+
+
+class TestLoggingConnection(unittest.TestCase):
+ def test_debug_method_uses_log_class(self):
+ with StringIO() as fh:
+ libcloud.enable_debug(fh)
+ conn = Connection(timeout=10)
+ conn.connect()
+ self.assertTrue(isinstance(conn.connection, LoggingConnection))
+
+ def test_debug_log_class_handles_request(self):
+ with StringIO() as fh:
+ libcloud.enable_debug(fh)
+ conn = Connection(url='http://test.com/')
+ conn.connect()
+ self.assertEqual(conn.connection.host, 'http://test.com')
+ with requests_mock.mock() as m:
+ m.get('http://test.com/test', text='data')
+ response = conn.request('/test')
+ self.assertEqual(response.body, 'data')
+ self.assertTrue(isinstance(conn.connection, LoggingConnection))
+
+if __name__ == '__main__':
+ sys.exit(unittest.main())
[3/3] libcloud git commit: changes for #978
Posted by an...@apache.org.
changes for #978
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/419c6944
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/419c6944
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/419c6944
Branch: refs/heads/trunk
Commit: 419c69441ea10e7bbf37319e5e8d02e82e7e6b40
Parents: 57c5929
Author: Anthony Shaw <an...@apache.org>
Authored: Wed Jan 18 15:41:45 2017 +1100
Committer: Anthony Shaw <an...@apache.org>
Committed: Wed Jan 18 15:41:45 2017 +1100
----------------------------------------------------------------------
CHANGES.rst | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/419c6944/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index ee6f70d..5b1420c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,6 +7,10 @@ Changes Apache Libcloud 2.0.0rc1
Common
~~~~~~
+- Fix DEBUG mode, also add support for using io.StringIO as the file handle when calling libcloud.enable_debug
+ [GITHUB-978, LIBCLOUD-887]
+ (Anthony Shaw)
+
- Introduction of the requests package as the mechanism for making HTTP requests for all drivers
[GITHUB-928]
(Anthony Shaw)
[2/3] libcloud git commit: fix and also support for StringIO as
enable_debug file handle argument
Posted by an...@apache.org.
fix and also support for StringIO as enable_debug file handle argument
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/57c5929b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/57c5929b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/57c5929b
Branch: refs/heads/trunk
Commit: 57c5929bcab251560bacd1fd7c067a27bf6ed9ac
Parents: ed6d012
Author: Anthony Shaw <an...@apache.org>
Authored: Wed Jan 18 15:20:56 2017 +1100
Committer: Anthony Shaw <an...@apache.org>
Committed: Wed Jan 18 15:20:56 2017 +1100
----------------------------------------------------------------------
libcloud/test/test_logging_connection.py | 10 ++++++++--
libcloud/utils/loggingconnection.py | 15 +++++++--------
2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/57c5929b/libcloud/test/test_logging_connection.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_logging_connection.py b/libcloud/test/test_logging_connection.py
index 3824838..e7088a4 100644
--- a/libcloud/test/test_logging_connection.py
+++ b/libcloud/test/test_logging_connection.py
@@ -20,10 +20,14 @@ import requests_mock
import libcloud
from libcloud.test import unittest
from libcloud.common.base import Connection
+from libcloud.httplib_ssl import LibcloudConnection
from libcloud.utils.loggingconnection import LoggingConnection
class TestLoggingConnection(unittest.TestCase):
+ def tearDown(self):
+ Connection.conn_class = LibcloudConnection
+
def test_debug_method_uses_log_class(self):
with StringIO() as fh:
libcloud.enable_debug(fh)
@@ -39,9 +43,11 @@ class TestLoggingConnection(unittest.TestCase):
self.assertEqual(conn.connection.host, 'http://test.com')
with requests_mock.mock() as m:
m.get('http://test.com/test', text='data')
- response = conn.request('/test')
- self.assertEqual(response.body, 'data')
+ conn.request('/test')
+ log = fh.getvalue()
self.assertTrue(isinstance(conn.connection, LoggingConnection))
+ self.assertIn('-i -X GET', log)
+ self.assertIn('data', log)
if __name__ == '__main__':
sys.exit(unittest.main())
http://git-wip-us.apache.org/repos/asf/libcloud/blob/57c5929b/libcloud/utils/loggingconnection.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/loggingconnection.py b/libcloud/utils/loggingconnection.py
index adea0ba..1e3ff41 100644
--- a/libcloud/utils/loggingconnection.py
+++ b/libcloud/utils/loggingconnection.py
@@ -27,7 +27,7 @@ import os
from libcloud.common.base import (LibcloudConnection,
HttpLibResponseProxy)
-from libcloud.utils.py3 import u
+from libcloud.utils.py3 import _real_unicode as u
from libcloud.utils.misc import lowercase_keys
from libcloud.utils.compression import decompress_data
@@ -42,7 +42,6 @@ class LoggingConnection(LibcloudConnection):
"""
protocol = 'https'
- port = None
log = None
http_proxy_used = False
@@ -133,24 +132,24 @@ class LoggingConnection(LibcloudConnection):
cmd.extend(["--data-binary", pquote(body)])
cmd.extend(["--compress"])
- cmd.extend([pquote("%s://%s:%d%s" % (self.protocol, self.host,
- self.port, url))])
+ cmd.extend([pquote("%s%s" % (self.host, url))])
return " ".join(cmd)
def getresponse(self):
original_response = LibcloudConnection.getresponse(self)
if self.log is not None:
rv = self._log_response(HttpLibResponseProxy(original_response))
- self.log.write(rv + "\n")
+ self.log.write(u(rv + "\n"))
self.log.flush()
return original_response
- def request(self, method, url, body=None, headers=None):
+ def request(self, method, url, body=None, headers=None, **kwargs):
headers.update({'X-LC-Request-ID': str(id(self))})
if self.log is not None:
pre = "# -------- begin %d request ----------\n" % id(self)
- self.log.write(pre +
- self._log_curl(method, url, body, headers) + "\n")
+ self.log.write(u(pre +
+ self._log_curl(method, url, body, headers) +
+ "\n"))
self.log.flush()
return LibcloudConnection.request(self, method, url, body,
headers)