diff --git a/changes/786.housekeeping b/changes/786.housekeeping new file mode 100644 index 00000000..581d3a9e --- /dev/null +++ b/changes/786.housekeeping @@ -0,0 +1 @@ +Fixed incorrect test data setup for `test_tags_filter()` test for `ConfigPlanFilterTestCase`. diff --git a/nautobot_golden_config/filters.py b/nautobot_golden_config/filters.py index 4e36ba24..45717400 100644 --- a/nautobot_golden_config/filters.py +++ b/nautobot_golden_config/filters.py @@ -300,9 +300,17 @@ class Meta: class ConfigPlanFilterSet(NautobotFilterSet): """Inherits Base Class NautobotFilterSet.""" - q = django_filters.CharFilter( - method="search", - label="Search", + q = SearchFilter( + filter_predicates={ + "device__name": { + "lookup_expr": "icontains", + "preprocessor": str, + }, + "change_control_id": { + "lookup_expr": "icontains", + "preprocessor": str, + }, + }, ) device_id = django_filters.ModelMultipleChoiceFilter( queryset=Device.objects.all(), @@ -421,20 +429,6 @@ class ConfigPlanFilterSet(NautobotFilterSet): to_field_name="name", label="Status", ) - # tags = TagFilter() - - q = SearchFilter( - filter_predicates={ - "device__name": { - "lookup_expr": "icontains", - "preprocessor": str, - }, - "change_control_id": { - "lookup_expr": "icontains", - "preprocessor": str, - }, - }, - ) class Meta: """Boilerplate filter Meta data for Config Plan.""" diff --git a/nautobot_golden_config/tests/test_filters.py b/nautobot_golden_config/tests/test_filters.py index 78657166..c9eb46d4 100644 --- a/nautobot_golden_config/tests/test_filters.py +++ b/nautobot_golden_config/tests/test_filters.py @@ -1,5 +1,6 @@ """Unit tests for nautobot_golden_config models.""" +from django.contrib.contenttypes.models import ContentType from django.test import TestCase from nautobot.dcim.models import Device, Platform from nautobot.extras.models import Status, Tag @@ -404,6 +405,8 @@ def setUp(self): self.status2 = Status.objects.get(name="Approved") self.tag1, _ = Tag.objects.get_or_create(name="Tag 1") self.tag2, _ = Tag.objects.get_or_create(name="Tag 2") + self.tag1.content_types.set([ContentType.objects.get_for_model(models.ConfigPlan)]) + self.tag2.content_types.set([ContentType.objects.get_for_model(models.ConfigPlan)]) self.job_result1 = create_job_result() self.job_result2 = create_job_result() self.config_plan1 = models.ConfigPlan.objects.create(