diff --git a/opsramp/api.py b/opsramp/api.py index e27955a..0ce8bfb 100755 --- a/opsramp/api.py +++ b/opsramp/api.py @@ -40,9 +40,6 @@ def b64encode_payload(fname): content = base64.b64encode(f.read()) return content.decode() - def get(self, suffix='', headers=None): - return self.api.get(suffix, headers) - def search(self, pattern='', headers=None, suffix='search'): if pattern: if pattern[0] != '?': diff --git a/opsramp/base.py b/opsramp/base.py index d32a163..eb3a30d 100755 --- a/opsramp/base.py +++ b/opsramp/base.py @@ -305,3 +305,6 @@ def __init__(self, apiobject, suffix=''): def __str__(self): return '%s %s' % (str(type(self)), self.api) + + def get(self, suffix='', headers=None): + return self.api.get(suffix, headers) diff --git a/tests/test_api_class.py b/tests/test_api_class.py index 97bba05..fbc7181 100644 --- a/tests/test_api_class.py +++ b/tests/test_api_class.py @@ -306,3 +306,20 @@ def test_patch(self): m.patch(url, text=expected) actual = self.ao.patch() assert actual == expected + + # We're not testing an exhaustive set of suffix patterns here because + # that is already being done by the ApiObject unit tests. Just + # get() and get(something) is enough. + def test_wrapped_get(self): + with requests_mock.Mocker() as m: + url = self.awrapper.api.compute_url() + expected = 'unit test wrapped get result' + m.get(url, text=expected, complete_qs=True) + actual = self.awrapper.get() + assert actual == expected + with requests_mock.Mocker() as m: + suffix = 'some/where/random' + url = self.awrapper.api.compute_url(suffix) + m.get(url, text=expected, complete_qs=True) + actual = self.awrapper.get(suffix) + assert actual == expected