mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-21 16:31:38 +02:00
Ensure all model FilterSets support the 'id' field
This commit is contained in:
@@ -49,7 +49,7 @@ class SecretFilterSet(BaseFilterSet, CustomFieldFilterSet, CreatedUpdatedFilterS
|
||||
|
||||
class Meta:
|
||||
model = Secret
|
||||
fields = ['name']
|
||||
fields = ['id', 'name']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
|
||||
@@ -20,8 +20,7 @@ class SecretRoleTestCase(TestCase):
|
||||
SecretRole.objects.bulk_create(roles)
|
||||
|
||||
def test_id(self):
|
||||
id_list = self.queryset.values_list('id', flat=True)[:2]
|
||||
params = {'id': [str(id) for id in id_list]}
|
||||
params = {'id': self.queryset.values_list('pk', flat=True)[:2]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_name(self):
|
||||
@@ -68,6 +67,10 @@ class SecretTestCase(TestCase):
|
||||
for s in secrets:
|
||||
s.save()
|
||||
|
||||
def test_id(self):
|
||||
params = {'id': self.queryset.values_list('pk', flat=True)[:2]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Secret 1', 'Secret 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
Reference in New Issue
Block a user