Skip to content

Commit

Permalink
tests: cover HubProxy proxying (__getattr__)
Browse files Browse the repository at this point in the history
This method was previously covered incidentally only by the
auto_logout feature which was removed. Add an explicit test for
it so that coverage doesn't decrease.
  • Loading branch information
rohanpm committed Jun 29, 2020
1 parent f379a5b commit 7839905
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_hubproxy.py
@@ -1,6 +1,7 @@
import pytest
import gssapi
import mock
import sys

from kobo.xmlrpc import SafeCookieTransport
from kobo.conf import PyConfigParser
Expand All @@ -25,8 +26,17 @@ class FakeTransport(SafeCookieTransport):
Subclasses the real SafeCookieTransport so we get a real CookieJar.
"""
def __init__(self, *args, **kwargs):
# note: py2 transport classes do not subclass object
if sys.version_info[0] < 3:
SafeCookieTransport.__init__(self, *args, **kwargs)
else:
super().__init__(*args, **kwargs)

self.fake_transport_calls = []

def request(self, host, path, request, verbose=False):
self.fake_transport_calls.append((path, request))
return []


Expand Down Expand Up @@ -166,3 +176,18 @@ def test_no_auto_logout(requests_session):
transport = FakeTransport()
with pytest.deprecated_call():
HubProxy(conf, transport=transport, auto_logout=True)


def test_proxies_to_xmlrpc(requests_session):
"""HubProxy proxies to underlying XML-RPC ServerProxy"""
conf = PyConfigParser()
conf.load_from_dict({"HUB_URL": 'https://example.com/hub'})

transport = FakeTransport()
proxy = HubProxy(conf, transport=transport)

proxy.some_obj.some_method()

# Last call should have invoked the method I requested
(_, request_xml) = transport.fake_transport_calls[-1]
assert b'some_obj.some_method' in request_xml

0 comments on commit 7839905

Please sign in to comment.