1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduce BaseFilterSetTests to standardize testing of PK filters

This commit is contained in:
jeremystretch
2021-05-03 14:36:44 -04:00
parent fbffef1cc4
commit ffa4cd134b
10 changed files with 93 additions and 337 deletions

View File

@ -1,4 +1,5 @@
from .api import *
from .base import *
from .filtersets import *
from .utils import *
from .views import *

View File

@ -0,0 +1,16 @@
__all__ = (
'BaseFilterSetTests',
)
class BaseFilterSetTests:
queryset = None
filterset = None
def test_id(self):
"""
Test filtering for two PKs from a set of >2 objects.
"""
params = {'id': self.queryset.values_list('pk', flat=True)[:2]}
self.assertGreater(self.queryset.count(), 2)
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)