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:
@ -1,4 +1,5 @@
|
||||
from .api import *
|
||||
from .base import *
|
||||
from .filtersets import *
|
||||
from .utils import *
|
||||
from .views import *
|
||||
|
16
netbox/utilities/testing/filtersets.py
Normal file
16
netbox/utilities/testing/filtersets.py
Normal 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)
|
Reference in New Issue
Block a user