From 242caf88fd1ed1c688ce4d86a6ce6f3c0b19d757 Mon Sep 17 00:00:00 2001 From: Zach Moody Date: Thu, 15 Apr 2021 11:03:13 -0500 Subject: [PATCH] Account for list returning from create Fixes #369 - When response_loader was removed the work it was doing to account for lists returning from queries was missed. --- pynetbox/core/endpoint.py | 2 ++ tests/integration/test_dcim.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pynetbox/core/endpoint.py b/pynetbox/core/endpoint.py index 48cb6fd6..b2c660a1 100644 --- a/pynetbox/core/endpoint.py +++ b/pynetbox/core/endpoint.py @@ -308,6 +308,8 @@ def create(self, *args, **kwargs): http_session=self.api.http_session, ).post(args[0] if args else kwargs) + if isinstance(req, list): + return [self.return_obj(i, self.api, self) for i in req] return self.return_obj(req, self.api, self) def choices(self): diff --git a/tests/integration/test_dcim.py b/tests/integration/test_dcim.py index 2ae410c6..6f5d2880 100644 --- a/tests/integration/test_dcim.py +++ b/tests/integration/test_dcim.py @@ -90,10 +90,12 @@ def init(self, request, site): @pytest.fixture(scope="class") def add_sites(self, api): - sites = [ - api.dcim.sites.create(name="test{}".format(i), slug="test{}".format(i)) - for i in range(2, 20) - ] + sites = api.dcim.sites.create( + [ + {"name": "test{}".format(i), "slug": "test{}".format(i)} + for i in range(2, 20) + ] + ) yield for i in sites: i.delete()