Skip to content

Commit

Permalink
Merge pull request #261 from nautobot/develop
Browse files Browse the repository at this point in the history
Release v2.4.2
  • Loading branch information
joewesch authored Nov 25, 2024
2 parents 33c3895 + fcb54a2 commit 306cbe6
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 113 deletions.
2 changes: 1 addition & 1 deletion development/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NAUTOBOT_DB_PASSWORD=decinablesprewad
NAUTOBOT_DB_USER=nautobot
NAUTOBOT_DB_TIMEOUT=300
NAUTOBOT_DB_ENGINE=django.db.backends.postgresql
NAUTOBOT_MAX_PAGE_SIZE=0
NAUTOBOT_MAX_PAGE_SIZE=100
NAUTOBOT_NAPALM_TIMEOUT=5
NAUTOBOT_REDIS_HOST=redis
NAUTOBOT_REDIS_PASSWORD=decinablesprewad
Expand Down
9 changes: 8 additions & 1 deletion docs/admin/release_notes/version_2.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@

(#248) Added support for new cloud models found in Nautobot 2.3+

##v2.4.1
## v2.4.1

### Fixed

- (#253) Fixed missing json data returned on cloud endpoints

## v2.4.2

### Fixed

- (#257) Fixed issue with pagination looping under certain conditions
- (#259) Fixed the `filter` field that was missing from dynamic group objects
232 changes: 123 additions & 109 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pynautobot/core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,13 @@ def req_all(add_params):
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"] and self.offset is None:
if not add_params:
if not add_params and 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:
Expand Down
2 changes: 2 additions & 0 deletions pynautobot/models/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def run(self, *args, **kwargs):


class DynamicGroups(Record):
filter = JsonField

def __str__(self):
parent_record_string = super().__str__()
return parent_record_string or str(self.id)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[tool.poetry]
name = "pynautobot"
version = "2.4.1"
version = "2.4.2"
description = "Nautobot API client library"
authors = ["Network to Code, LLC <opensource@networktocode.com>"]
readme = "README.md"
Expand All @@ -27,6 +27,7 @@ packaging = "^23.2"
[tool.poetry.group.dev.dependencies]
requests-mock = "^1.12.1"
pytest = "^8.1.1"
pytest-timeout = "^2.3.1"
mkdocs = "^1.6.0"
watchdog = "^4.0.0"
mkdocs-material = "9.5.32"
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/test_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,31 @@ def test_graphql_query_run_with_variable(self, create_graphql_query):
data = query.run(variables={"devicename": "dev-1"})
assert len(data.get("data", {}).get("devices")) == 1
assert data.get("data", {}).get("devices")[0].get("name") == "dev-1"


class TestDynamicGroup:
"""Dynamic group tests."""

def test_dynamic_group_filter_field(self, nb_client):
"""Verify we can create a dynamic group and return the filter field."""

# Define filter field
obj_filter = {"q": "foobar"}

# Create dynamic group
nb_client.extras.dynamic_groups.create(
[
{
"name": "TestDynamicGroup",
"content_type": "dcim.device",
"group_type": "dynamic-filter",
"filter": obj_filter,
}
]
)

# Get dynamic group
dynamic_group = nb_client.extras.dynamic_groups.get(name="TestDynamicGroup")

# Assert filter field is returned
assert dynamic_group.filter == obj_filter
14 changes: 14 additions & 0 deletions tests/integration/test_ipam.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from pynautobot.core.response import Record


Expand Down Expand Up @@ -26,3 +27,16 @@ def test_prefixes_successfully_stringify_tags(nb_client):
assert "192.0.2.0/24" in str(prefix)
assert prefix.tags
assert isinstance(prefix.tags[0], Record)


@pytest.mark.timeout(120)
def test_prefixes_pagination_with_max_page_size(nb_client):
"""Validate prefixes are returned when dataset is larger than max_page_size and not in endless loop."""
nb_client.ipam.prefixes.create(
[
{"prefix": f"192.1.{str(i)}.0/24", "namespace": {"name": "Global"}, "status": {"name": "Active"}}
for i in range(0, 256)
]
)
prefixes = nb_client.ipam.prefixes.all()
assert len(prefixes) >= 255

0 comments on commit 306cbe6

Please sign in to comment.