Repository: digitalocean/pynetbox (python)

Issue:
Use Requests Param to build URL instead of Request.url

Pull request description:
Fixes #133 - Use requests params to form URL parameters

Patch:
diff --git a/pynetbox/core/endpoint.py b/pynetbox/core/endpoint.py
index 919e07f..7101748 100644
--- a/pynetbox/core/endpoint.py
+++ b/pynetbox/core/endpoint.py
@@ -427,11 +427,7 @@ class DetailEndpoint(object):
         :returns: A dictionary or list of dictionaries retrieved from
             NetBox.
         """
-        if kwargs:
-            self.request_kwargs["base"] = "{}{}".format(
-                self.url, url_param_builder(kwargs)
-            )
-        req = Request(**self.request_kwargs).get()
+        req = Request(**self.request_kwargs).get(add_params=kwargs)
 
         if self.custom_return:
             if isinstance(req, list):
diff --git a/pynetbox/core/query.py b/pynetbox/core/query.py
index 74d0f21..934ddd8 100644
--- a/pynetbox/core/query.py
+++ b/pynetbox/core/query.py
@@ -69,7 +69,7 @@ class RequestError(Exception):
         super(RequestError, self).__init__(message)
         self.req = req
         self.request_body = req.request.body
-        self.url = req.url
+        self.base = req.url
         self.error = req.text
 
 
@@ -88,7 +88,7 @@ class AllocationError(Exception):
         super(AllocationError, self).__init__(message)
         self.req = req
         self.request_body = req.request.body
-        self.url = req.url
+        self.base = req.url
         self.error = message
 
 
@@ -111,7 +111,7 @@ class ContentError(Exception):
         super(ContentError, self).__init__(message)
         self.req = req
         self.request_body = req.request.body
-        self.url = req.url
+        self.base = req.url
         self.error = message
 
 
@@ -154,7 +154,7 @@ class Request(object):
             private_key (string, optional): The user's private key as a
                 string.
         """
-        self.base = base
+        self.base = self.normalize_url(base)
         self.filters = filters
         self.key = key
         self.token = token
@@ -162,6 +162,7 @@ class Request(object):
         self.session_key = session_key
         self.ssl_verify = ssl_verify
         self.http_session = http_session
+        self.url = self.base if not key else "{}{}/".format(self.base, key)
 
     def get_version(self):
         """ Gets the API version of NetBox.
@@ -177,7 +178,7 @@ class Request(object):
             "Content-Type": "application/json;",
         }
         req = requests.get(
-            self.normalize_url(self.url),
+            self.normalize_url(self.base),
             headers=headers,
             verify=self.ssl_verify,
         )
@@ -212,44 +213,6 @@ class Request(object):
         else:
             raise RequestError(req)
 
-    @property
-    def url(self):
-        """ Builds a URL.
-        Creates a valid netbox url based on kwargs passed during
-        instantiation.
-
-        :Returns: String of URL.
-        """
-
-        def construct_url(params):
-            for k, v in params.items():
-                if isinstance(v, list):
-                    for i in v:
-                        yield urlencode({k: i})
-                else:
-                    yield urlencode({k: v})
-
-        if self.key:
-            return "{}/{key}/".format(self.base, key=self.key)
-        if self.filters:
-            if self.base[-1] == "/":
-                return "{}?{query}".format(
-                    self.base,
-                    query="&".join(list(construct_url(self.filters))),
-                )
-            elif "/?" in self.base:
-                return "{}&{query}".format(
-                    self.base,
-                    query="&".join(list(construct_url(self.filters))),
-                )
-            else:
-                return "{}/?{query}".format(
-                    self.base,
-                    query="&".join(list(construct_url(self.filters))),
-                )
-        else:
-            return self.base
-
     def normalize_url(self, url):
         """ Builds a url for POST actions.
         """
@@ -258,18 +221,38 @@ class Request(object):
 
         return url
 
-    def _make_call(self, url):
+    def _make_call(
+        self, verb="get", url_override=None, add_params=None, data=None
+    ):
+        if verb in ("post", "put"):
+            headers = {"Content-Type": "application/json;"}
+        else:
+            headers = {"accept": "application/json;"}
 
-        headers = {"accept": "application/json;"}
         if self.token:
-            headers.update(authorization="Token {}".format(self.token))
+            headers["authorization"] = "Token {}".format(self.token)
         if self.session_key:
-            headers.update({"X-Session-Key": self.session_key})
+            headers["X-Session-Key"] = self.session_key
 
-        req = self.http_session.get(
-            url, headers=headers, verify=self.ssl_verify
+        params = {}
+        if self.filters:
+            params = self.filters
+        if add_params:
+            params.update(add_params)
+
+        req = getattr(self.http_session, verb)(
+            url_override or self.url, headers=headers, verify=self.ssl_verify,
+            params=params, json=data
         )
-        if req.ok:
+
+        if req.status_code == 204 and verb == "post":
+            raise AllocationError(req)
+        if verb == "delete":
+            if req.ok:
+                return True
+            else:
+                raise RequestError(req)
+        elif req.ok:
             try:
                 return req.json()
             except json.JSONDecodeError:
@@ -277,7 +260,7 @@ class Request(object):
         else:
             raise RequestError(req)
 
-    def get(self):
+    def get(self, add_params=None):
         """Makes a GET request.
 
         Makes a GET request to NetBox's API, and automatically recurses
@@ -290,30 +273,29 @@ class Request(object):
             endpoint.
         """
 
-        def req_all(url):
-            req = self._make_call(url)
+        def req_all():
+            req = self._make_call(add_params=add_params)
             if isinstance(req, dict) and req.get("results") is not None:
                 ret = req["results"]
                 first_run = True
                 while req["next"]:
-                    next_url = (
-                        "{}{}limit={}&offset={}".format(
-                            self.url,
-                            "&" if self.url[-1] != "/" else "?",
-                            req["count"],
-                            len(req["results"]),
-                        )
-                        if first_run
-                        else req["next"]
-                    )
-                    req = self._make_call(next_url)
+                    # Not worrying about making sure add_params kwargs is
+                    # passed in here because results from detail routes aren't
+                    # paginated, thus far.
+                    if first_run:
+                        req = self._make_call(add_params={
+                            "limit": req["count"],
+                            "offset": len(req["results"])
+                        })
+                    else:
+                        req = self._make_call(url_override=req["next"])
                     first_run = False
                     ret.extend(req["results"])
                 return ret
             else:
                 return req
 
-        return req_all(self.url)
+        return req_all()
 
     def put(self, data):
         """Makes PUT request.
@@ -327,25 +309,7 @@ class Request(object):
         :raises: ContentError if response is not json.
         :returns: Dict containing the response from NetBox's API.
         """
-        headers = {
-            "Content-Type": "application/json;",
-            "authorization": "Token {}".format(self.token),
-        }
-        if self.session_key:
-            headers.update({"X-Session-Key": self.session_key})
-        req = self.http_session.put(
-            self.url,
-            headers=headers,
-            data=json.dumps(data),
-            verify=self.ssl_verify,
-        )
-        if req.ok:
-            try:
-                return req.json()
-            except json.JSONDecodeError:
-                raise ContentError(req)
-        else:
-            raise RequestError(req)
+        return self._make_call(verb="put", data=data)
 
     def post(self, data):
         """Makes POST request.
@@ -362,27 +326,7 @@ class Request(object):
         :raises: ContentError if response is not json.
         :Returns: Dict containing the response from NetBox's API.
         """
-        headers = {
-            "Content-Type": "application/json;",
-            "authorization": "Token {}".format(self.token),
-        }
-        if self.session_key:
-            headers.update({"X-Session-Key": self.session_key})
-        req = self.http_session.post(
-            self.normalize_url(self.url),
-            headers=headers,
-            data=json.dumps(data),
-            verify=self.ssl_verify,
-        )
-        if req.status_code == 204:
-            raise AllocationError(req)
-        elif req.ok:
-            try:
-                return req.json()
-            except json.JSONDecodeError:
-                raise ContentError(req)
-        else:
-            raise RequestError(req)
+        return self._make_call(verb="post", data=data)
 
     def delete(self):
         """Makes DELETE request.
@@ -395,17 +339,7 @@ class Request(object):
         Raises:
             RequestError if req.ok doesn't return True.
         """
-        headers = {
-            "accept": "application/json;",
-            "authorization": "Token {}".format(self.token),
-        }
-        req = self.http_session.delete(
-            "{}".format(self.url), headers=headers, verify=self.ssl_verify
-        )
-        if req.ok:
-            return True
-        else:
-            raise RequestError(req)
+        return self._make_call(verb="delete")
 
     def patch(self, data):
         """Makes PATCH request.
@@ -418,25 +352,7 @@ class Request(object):
         :raises: ContentError if response is not json.
         :returns: Dict containing the response from NetBox's API.
         """
-        headers = {
-            "Content-Type": "application/json;",
-            "authorization": "Token {}".format(self.token),
-        }
-        if self.session_key:
-            headers.update({"X-Session-Key": self.session_key})
-        req = self.http_session.patch(
-            self.url,
-            headers=headers,
-            data=json.dumps(data),
-            verify=self.ssl_verify,
-        )
-        if req.ok:
-            try:
-                return req.json()
-            except json.JSONDecodeError:
-                raise ContentError(req)
-        else:
-            raise RequestError(req)
+        return self._make_call(verb="patch", data=data)
 
     def options(self):
         """Makes an OPTIONS request.
@@ -448,24 +364,7 @@ class Request(object):
 
         :returns: Dict containing the response from NetBox's API.
         """
-        headers = {"accept": "application/json;"}
-        if self.token:
-            headers.update(authorization="Token {}".format(self.token))
-        if self.session_key:
-            headers.update({"X-Session-Key": self.session_key})
-
-        req = requests.options(
-            self.url,
-            headers=headers,
-            verify=self.ssl_verify,
-        )
-        if req.ok:
-            try:
-                return req.json()
-            except json.JSONDecodeError:
-                raise ContentError(req)
-        else:
-            raise RequestError(req)
+        return self._make_call(verb="options")
 
     def get_count(self, *args, **kwargs):
         """Returns object count for query
@@ -479,6 +378,4 @@ class Request(object):
         :returns: Int of number of objects query returned.
         """
 
-        return self._make_call(
-            "{}{}limit=1".format(self.url, "/?" if not self.filters else "&")
-        )["count"]
+        return self._make_call(add_params={"limit": 1})["count"]


Test patch:
diff --git a/tests/test_circuits.py b/tests/test_circuits.py
index fd0961f..add97dd 100644
--- a/tests/test_circuits.py
+++ b/tests/test_circuits.py
@@ -43,6 +43,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -60,10 +62,12 @@ class Generic(object):
                 self.assertTrue(isinstance(ret, list))
                 self.assertTrue(isinstance(ret[0], self.ret))
                 mock.assert_called_with(
-                    'http://localhost:8000/api/{}/{}/?name=test'.format(
+                    'http://localhost:8000/api/{}/{}/'.format(
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={"name": "test"},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -84,6 +88,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
diff --git a/tests/test_dcim.py b/tests/test_dcim.py
index 94c2624..c00e1d8 100644
--- a/tests/test_dcim.py
+++ b/tests/test_dcim.py
@@ -12,17 +12,14 @@ else:
 
 api = pynetbox.api(
     "http://localhost:8000",
+    token="abc123",
 )
 
 nb = api.dcim
 
 HEADERS = {
     'accept': 'application/json;',
-}
-
-AUTH_HEADERS = {
-    'accept': 'application/json;',
-    'authorization': 'Token None',
+    'authorization': 'Token abc123',
 }
 
 
@@ -49,6 +46,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -66,10 +65,12 @@ class Generic(object):
                 self.assertTrue(isinstance(ret, list))
                 self.assertTrue(isinstance(ret[0], self.ret))
                 mock.assert_called_with(
-                    'http://localhost:8000/api/{}/{}/?name=test'.format(
+                    'http://localhost:8000/api/{}/{}/'.format(
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={"name": "test"},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -92,6 +93,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -111,6 +114,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -119,7 +124,9 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
-                    headers=AUTH_HEADERS,
+                    params={},
+                    json=None,
+                    headers=HEADERS,
                     verify=True
                 )
 
@@ -168,6 +175,8 @@ class DeviceTestCase(Generic.Tests):
                 self.app,
                 self.name.replace('_', '-')
             ),
+            params={},
+            json=None,
             headers=HEADERS,
             verify=True
         )
@@ -182,10 +191,12 @@ class DeviceTestCase(Generic.Tests):
         self.assertTrue(isinstance(ret, list))
         self.assertTrue(isinstance(ret[0], self.ret))
         mock.assert_called_with(
-            'http://localhost:8000/api/{}/{}/?role=test&role=test1&site=TEST%231'.format(
+            'http://localhost:8000/api/{}/{}/'.format(
                 self.app,
                 self.name.replace('_', '-')
             ),
+            params={'role': ['test', 'test1'], 'site': 'TEST#1'},
+            json=None,
             headers=HEADERS,
             verify=True
         )
@@ -269,7 +280,9 @@ class DeviceTestCase(Generic.Tests):
         test = nb.devices.get(1)
         ret = test.napalm.list(method='get_facts')
         mock.assert_called_with(
-            'http://localhost:8000/api/dcim/devices/1/napalm/?method=get_facts',
+            'http://localhost:8000/api/dcim/devices/1/napalm/',
+            params={"method": "get_facts"},
+            json=None,
             headers=HEADERS,
             verify=True,
         )
@@ -354,7 +367,9 @@ class InterfaceTestCase(Generic.Tests):
         self.assertTrue(isinstance(ret[0], self.ret))
         self.assertEqual(len(ret), 71)
         mock.assert_called_with(
-            'http://localhost:8000/api/dcim/interfaces/?limit=221&offset=50',
+            'http://localhost:8000/api/dcim/interfaces/',
+            params={"limit": 221, "offset": 50},
+            json=None,
             headers=HEADERS,
             verify=True
         )
@@ -375,6 +390,8 @@ class RackTestCase(Generic.Tests):
         ret = test.units.list()
         mock.assert_called_with(
             'http://localhost:8000/api/dcim/racks/1/units/',
+            params={},
+            json=None,
             headers=HEADERS,
             verify=True,
         )
@@ -490,6 +507,8 @@ class Choices(unittest.TestCase):
             self.assertTrue(ret)
             mock.assert_called_with(
                 'http://localhost:8000/api/dcim/_choices/',
+                params={},
+                json=None,
                 headers=HEADERS,
                 verify=True
             )
@@ -552,5 +571,7 @@ class CablesTestCase(Generic.Tests):
                     self.name.replace('_', '-')
                 ),
                 headers=HEADERS,
+                params={},
+                json=None,
                 verify=True
             )
diff --git a/tests/test_ipam.py b/tests/test_ipam.py
index 712a80b..287a706 100644
--- a/tests/test_ipam.py
+++ b/tests/test_ipam.py
@@ -14,17 +14,19 @@ else:
 
 api = pynetbox.api(
     "http://localhost:8000",
+    token="abc123",
 )
 
 nb = api.ipam
 
 HEADERS = {
-    'accept': 'application/json;'
+    'accept': 'application/json;',
+    'authorization': 'Token abc123',
 }
 
 POST_HEADERS = {
     'Content-Type': 'application/json;',
-    'authorization': 'Token None',
+    'authorization': 'Token abc123',
 }
 
 
@@ -52,6 +54,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -69,10 +73,12 @@ class Generic(object):
                 self.assertTrue(isinstance(ret, list))
                 self.assertTrue(isinstance(ret[0], self.ret))
                 mock.assert_called_with(
-                    'http://localhost:8000/api/{}/{}/?name=test'.format(
+                    'http://localhost:8000/api/{}/{}/'.format(
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={"name": "test"},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -95,6 +101,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -141,6 +149,8 @@ class PrefixTestCase(Generic.Tests):
         ret = pfx.available_ips.list()
         mock.assert_called_with(
             'http://localhost:8000/api/ipam/prefixes/1/available-ips/',
+            params={},
+            json=None,
             headers=HEADERS,
             verify=True
         )
@@ -175,8 +185,9 @@ class PrefixTestCase(Generic.Tests):
         ret = pfx.available_ips.create(create_parms)
         post.assert_called_with(
             'http://localhost:8000/api/ipam/prefixes/1/available-ips/',
+            params={},
             headers=POST_HEADERS,
-            data=json.dumps(create_parms),
+            json=create_parms,
             verify=True
         )
         self.assertTrue(ret)
@@ -194,6 +205,8 @@ class PrefixTestCase(Generic.Tests):
         ret = pfx.available_prefixes.list()
         mock.assert_called_with(
             'http://localhost:8000/api/ipam/prefixes/1/available-prefixes/',
+            params={},
+            json=None,
             headers=HEADERS,
             verify=True
         )
@@ -215,8 +228,9 @@ class PrefixTestCase(Generic.Tests):
         ret = pfx.available_prefixes.create(create_parms)
         post.assert_called_with(
             'http://localhost:8000/api/ipam/prefixes/1/available-prefixes/',
+            params={},
             headers=POST_HEADERS,
-            data=json.dumps(create_parms),
+            json=create_parms,
             verify=True
         )
         self.assertTrue(ret)
diff --git a/tests/test_tenancy.py b/tests/test_tenancy.py
index a9e392c..8b51d1d 100644
--- a/tests/test_tenancy.py
+++ b/tests/test_tenancy.py
@@ -44,6 +44,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -61,10 +63,12 @@ class Generic(object):
                 self.assertTrue(isinstance(ret, list))
                 self.assertTrue(isinstance(ret[0], self.ret))
                 mock.assert_called_with(
-                    'http://localhost:8000/api/{}/{}/?name=test'.format(
+                    'http://localhost:8000/api/{}/{}/'.format(
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={"name": "test"},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -85,6 +89,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
diff --git a/tests/test_virtualization.py b/tests/test_virtualization.py
index 07ff62d..63e19f4 100644
--- a/tests/test_virtualization.py
+++ b/tests/test_virtualization.py
@@ -44,6 +44,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -61,10 +63,12 @@ class Generic(object):
                 self.assertTrue(isinstance(ret, list))
                 self.assertTrue(isinstance(ret[0], self.ret))
                 mock.assert_called_with(
-                    'http://localhost:8000/api/{}/{}/?name=test'.format(
+                    'http://localhost:8000/api/{}/{}/'.format(
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={"name": "test"},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
@@ -85,6 +89,8 @@ class Generic(object):
                         self.app,
                         self.name.replace('_', '-')
                     ),
+                    params={},
+                    json=None,
                     headers=HEADERS,
                     verify=True
                 )
diff --git a/tests/unit/test_endpoint.py b/tests/unit/test_endpoint.py
index f4c1ffd..d83c386 100644
--- a/tests/unit/test_endpoint.py
+++ b/tests/unit/test_endpoint.py
@@ -38,42 +38,3 @@ class EndPointTestCase(unittest.TestCase):
         test_obj = Endpoint(api, app, "test")
         with self.assertRaises(ValueError) as _:
             test_obj.filter(id=1)
-
-    def test_count(self):
-        with patch(
-            "pynetbox.core.query.Request._make_call", return_value={"count": 42}
-        ) as mock:
-            api = Mock(base_url="http://localhost:8000/api")
-            app = Mock()
-            app.name = "test-app"
-            expected_call = call('http://localhost:8000/api/test-app/test-endpoint/?test_filter=test&limit=1')
-            test_obj = Endpoint(api, app, "test_endpoint")
-            test = test_obj.count(test_filter="test")
-            self.assertEqual(test, 42)
-            self.assertEqual(mock.call_args, expected_call)
-
-    def test_count_args(self):
-        with patch(
-            "pynetbox.core.query.Request._make_call", return_value={"count": 42}
-        ) as mock:
-            api = Mock(base_url="http://localhost:8000/api")
-            app = Mock()
-            app.name = "test-app"
-            expected_call = call('http://localhost:8000/api/test-app/test-endpoint/?q=test&limit=1')
-            test_obj = Endpoint(api, app, "test_endpoint")
-            test = test_obj.count("test")
-            self.assertEqual(test, 42)
-            self.assertEqual(mock.call_args, expected_call)
-
-    def test_count_no_args(self):
-        with patch(
-            "pynetbox.core.query.Request._make_call", return_value={"count": 42}
-        ) as mock:
-            api = Mock(base_url="http://localhost:8000/api")
-            app = Mock()
-            app.name = "test-app"
-            expected_call = call('http://localhost:8000/api/test-app/test-endpoint/?limit=1')
-            test_obj = Endpoint(api, app, "test_endpoint")
-            test = test_obj.count()
-            self.assertEqual(test, 42)
-            self.assertEqual(mock.call_args, expected_call)
diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py
index e802503..e260548 100644
--- a/tests/unit/test_query.py
+++ b/tests/unit/test_query.py
@@ -24,14 +24,21 @@ class RequestTestCase(unittest.TestCase):
             "results": [],
         }
         expected = call(
-            "http://localhost:8001/api/dcim/devices/?q=abcd&limit=1",
+            "http://localhost:8001/api/dcim/devices/",
+            params={"q": "abcd", "limit": 1},
             headers={"accept": "application/json;"},
             verify=True,
         )
         test_obj.http_session.get.ok = True
         test = test_obj.get_count()
         self.assertEqual(test, 42)
-        self.assertEqual(test_obj.http_session.get.call_args, expected)
+        test_obj.http_session.get.assert_called_with(
+            "http://localhost:8001/api/dcim/devices/",
+            params={"q": "abcd", "limit": 1},
+            headers={"accept": "application/json;"},
+            json=None,
+            verify=True,
+        )
 
     def test_get_count_no_filters(self):
         test_obj = Request(
@@ -44,12 +51,13 @@ class RequestTestCase(unittest.TestCase):
             "previous": False,
             "results": [],
         }
-        expected = call(
-            "http://localhost:8001/api/dcim/devices/?limit=1",
-            headers={"accept": "application/json;"},
-            verify=True,
-        )
         test_obj.http_session.get.ok = True
         test = test_obj.get_count()
         self.assertEqual(test, 42)
-        self.assertEqual(test_obj.http_session.get.call_args, expected)
+        test_obj.http_session.get.assert_called_with(
+            "http://localhost:8001/api/dcim/devices/",
+            params={"limit": 1},
+            headers={"accept": "application/json;"},
+            json=None,
+            verify=True,
+        )