Skip to content

Commit 873ff43

Browse files
author
Zach Moody
authored
Merge pull request #345 from digitalocean/fix-threaded-returns
Fix threaded returns
2 parents d2c6b16 + 8f65915 commit 873ff43

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

pynetbox/core/query.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __init__(
130130
base,
131131
http_session,
132132
filters=None,
133-
limit=0,
133+
limit=None,
134134
key=None,
135135
token=None,
136136
private_key=None,
@@ -307,6 +307,8 @@ def get(self, add_params=None):
307307
endpoint.
308308
"""
309309

310+
if not add_params and self.limit is not None:
311+
add_params = {"limit": self.limit}
310312
req = self._make_call(add_params=add_params)
311313
if isinstance(req, dict) and req.get("results") is not None:
312314
self.count = req["count"]
@@ -323,7 +325,8 @@ def get(self, add_params=None):
323325
ret.extend(req["results"])
324326
else:
325327
self.concurrent_get(ret, page_size, page_offsets)
326-
return ret
328+
for i in ret:
329+
yield i
327330
first_run = True
328331
for i in req["results"]:
329332
yield i

tests/test_circuits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_get_all(self):
3434
"http://localhost:8000/api/{}/{}/".format(
3535
self.app, self.name.replace("_", "-")
3636
),
37-
params={},
37+
params={"limit": 0},
3838
json=None,
3939
headers=HEADERS,
4040
)
@@ -51,7 +51,7 @@ def test_filter(self):
5151
"http://localhost:8000/api/{}/{}/".format(
5252
self.app, self.name.replace("_", "-")
5353
),
54-
params={"name": "test"},
54+
params={"name": "test", "limit": 0},
5555
json=None,
5656
headers=HEADERS,
5757
)

tests/test_tenancy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_get_all(self):
3535
"http://localhost:8000/api/{}/{}/".format(
3636
self.app, self.name.replace("_", "-")
3737
),
38-
params={},
38+
params={"limit": 0},
3939
json=None,
4040
headers=HEADERS,
4141
)
@@ -52,7 +52,7 @@ def test_filter(self):
5252
"http://localhost:8000/api/{}/{}/".format(
5353
self.app, self.name.replace("_", "-")
5454
),
55-
params={"name": "test"},
55+
params={"name": "test", "limit": 0},
5656
json=None,
5757
headers=HEADERS,
5858
)

tests/test_users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_get_all(self):
3535
"http://localhost:8000/api/{}/{}/".format(
3636
self.app, self.name.replace("_", "-")
3737
),
38-
params={},
38+
params={"limit": 0},
3939
json=None,
4040
headers=HEADERS,
4141
)
@@ -52,7 +52,7 @@ def test_filter(self):
5252
"http://localhost:8000/api/{}/{}/".format(
5353
self.app, self.name.replace("_", "-")
5454
),
55-
params={"name": "test"},
55+
params={"name": "test", "limit": 0},
5656
json=None,
5757
headers=HEADERS,
5858
)

tests/test_virtualization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_get_all(self):
3535
"http://localhost:8000/api/{}/{}/".format(
3636
self.app, self.name.replace("_", "-")
3737
),
38-
params={},
38+
params={"limit": 0},
3939
json=None,
4040
headers=HEADERS,
4141
)
@@ -52,7 +52,7 @@ def test_filter(self):
5252
"http://localhost:8000/api/{}/{}/".format(
5353
self.app, self.name.replace("_", "-")
5454
),
55-
params={"name": "test"},
55+
params={"name": "test", "limit": 0},
5656
json=None,
5757
headers=HEADERS,
5858
)

0 commit comments

Comments
 (0)