Skip to content

Commit

Permalink
Merge pull request #370 from digitalocean/fix-create-list
Browse files Browse the repository at this point in the history
Account for list returning from create
  • Loading branch information
Zach Moody committed Apr 15, 2021
2 parents 1605121 + 242caf8 commit ace1061
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pynetbox/core/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/test_dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ace1061

Please sign in to comment.