Skip to content

Commit

Permalink
hardware API andpoint implementation is incompatible with nautobot-an…
Browse files Browse the repository at this point in the history
…sible plugin module. (#290)

* Update HardwareLCMFilterSet

* Update unittest

* Set Nautobot to min 2.2.0

* Update Nautobot CI version to 2.2.1

---------

Co-authored-by: Przemek Rogala <progala@progala.net>
  • Loading branch information
pszulczewski and progala authored Aug 9, 2024
1 parent 3d2d553 commit 02bf22d
Show file tree
Hide file tree
Showing 8 changed files with 1,559 additions and 1,476 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
fail-fast: true
matrix:
python-version: ["3.11"]
nautobot-version: ["2.0.0"]
nautobot-version: ["2.2.1"]
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_PYTHON_VER: "${{ matrix.python-version }}"
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
include:
- python-version: "3.11"
db-backend: "postgresql"
nautobot-version: "2.0.0"
nautobot-version: "2.2.1"
# - python-version: "3.11"
# db-backend: "mysql"
# nautobot-version: "stable"
Expand Down
1 change: 1 addition & 0 deletions changes/290.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated HardwareLCMFilterSet filter field names for compatibility with nautobot-ansible plugin module.
1 change: 1 addition & 0 deletions development/app_config_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""App Config Schema Generator and Validator."""

import json
from importlib import import_module
from os import getenv
Expand Down
7 changes: 4 additions & 3 deletions nautobot_device_lifecycle_mgmt/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ class HardwareLCMFilterSet(NautobotFilterSet):
q = django_filters.CharFilter(method="search", label="Search")

device_type = django_filters.ModelMultipleChoiceFilter(
field_name="device_type", queryset=DeviceType.objects.all(), label="Device Type"
)

device_type_model = django_filters.ModelMultipleChoiceFilter(
field_name="device_type__model",
queryset=DeviceType.objects.all(),
to_field_name="model",
label="Device Type (Model)",
)
device_type_id = django_filters.ModelMultipleChoiceFilter(
field_name="device_type", queryset=DeviceType.objects.all(), label="Device Type"
)

inventory_item = django_filters.ModelMultipleChoiceFilter(
queryset=HardwareLCM.objects.exclude(inventory_item__isnull=True),
Expand Down
8 changes: 4 additions & 4 deletions nautobot_device_lifecycle_mgmt/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,22 @@ def test_documentation_url(self):

def test_device_type_name_single(self):
"""Test device_type filter."""
params = {"device_type": ["c9300-24"]}
params = {"device_type_model": ["c9300-24"]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

def test_device_types_name_all(self):
"""Test device_type filter."""
params = {"device_type": ["c9300-24", "c9300-48"]}
params = {"device_type_model": ["c9300-24", "c9300-48"]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)

def test_device_types_id_single(self):
"""Test device_type_id filter."""
params = {"device_type_id": [self.device_types[0].id]}
params = {"device_type": [self.device_types[0].id]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

def test_device_types_id_all(self):
"""Test device_type_id filter."""
params = {"device_type_id": [self.device_types[0].id, self.device_types[1].id]}
params = {"device_type": [self.device_types[0].id, self.device_types[1].id]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)

def test_devices_name_all(self):
Expand Down
3,009 changes: 1,544 additions & 1,465 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ matplotlib = "^3.3.4"
nautobot = "^2.2.0"

[tool.poetry.group.dev.dependencies]
Django = "~3.2.25"
bandit = "*"
black = "*"
coverage = "*"
Expand Down Expand Up @@ -126,7 +127,7 @@ notes = """,

[tool.pylint-nautobot]
supported_nautobot_versions = [
"2.0.0"
"2.2.0"
]

[tool.ruff]
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def autoformat(context):
"output_format": "see https://docs.astral.sh/ruff/settings/#output-format",
},
)
def ruff(context, action="lint", fix=False, output_format="text"):
def ruff(context, action="lint", fix=False, output_format="full"):
"""Run ruff to perform code formatting and/or linting."""
if action != "lint":
command = "ruff format"
Expand Down

0 comments on commit 02bf22d

Please sign in to comment.