Skip to content

Commit 0568cce

Browse files
authored
Merge pull request #268 from amcmahon-rh/transport_args
Add transport args as a kwarg for HubProxy [RHELDST-27818]
2 parents be7b4bd + 200c1e9 commit 0568cce

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

kobo/client/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ class ClientCommand(kobo.cli.Command):
129129
class HubProxy(object):
130130
"""A Hub client (thin ServerProxy wrapper)."""
131131

132-
def __init__(self, conf, client_type=None, logger=None, transport=None, auto_logout=None, **kwargs):
132+
def __init__(self, conf, client_type=None, logger=None, transport=None,
133+
auto_logout=None, transport_args=None, **kwargs):
133134
self._conf = kobo.conf.PyConfigParser()
134135
self._hub = None
135136

@@ -157,7 +158,7 @@ def __init__(self, conf, client_type=None, logger=None, transport=None, auto_log
157158
if transport is not None:
158159
self._transport = transport
159160
else:
160-
transport_args = {}
161+
transport_args = transport_args or {}
161162
if self._hub_url.startswith("https://"):
162163
TransportClass = kobo.xmlrpc.retry_request_decorator(kobo.xmlrpc.SafeCookieTransport)
163164
if hasattr(ssl, 'create_default_context'):

tests/test_hubproxy.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,18 @@ def test_proxies_to_xmlrpc(requests_session):
237237
# Last call should have invoked the method I requested
238238
(_, request_xml) = transport.fake_transport_calls[-1]
239239
assert b'some_obj.some_method' in request_xml
240+
241+
242+
def test_pass_transport_args(requests_session):
243+
"""HubProxy proxies to underlying XML-RPC ServerProxy"""
244+
conf = PyConfigParser()
245+
conf.load_from_dict({"HUB_URL": 'https://example.com/hub'})
246+
transport_args = {"retry_count": 2, "retry_timeout": 45}
247+
with mock.patch(
248+
"kobo.xmlrpc.SafeCookieTransport") as mock_transport_class, mock.patch(
249+
"kobo.xmlrpc.retry_request_decorator",
250+
return_value=mock_transport_class):
251+
HubProxy(conf, transport_args=transport_args)
252+
mock_transport_class.assert_called_with(context=mock.ANY,
253+
retry_count=2,
254+
retry_timeout=45)

0 commit comments

Comments
 (0)