diff --git a/netbox/utilities/tests/test_prefetch.py b/netbox/utilities/tests/test_prefetch.py new file mode 100644 index 000000000..9da35c12e --- /dev/null +++ b/netbox/utilities/tests/test_prefetch.py @@ -0,0 +1,17 @@ +from circuits.models import Circuit, Provider +from utilities.prefetch import get_prefetchable_fields +from utilities.testing.base import TestCase + + +class GetPrefetchableFieldsTest(TestCase): + """ + Verify the operation of get_prefetchable_fields() + """ + def test_get_prefetchable_fields(self): + field_names = get_prefetchable_fields(Provider) + self.assertIn('asns', field_names) # ManyToManyField + self.assertIn('circuits', field_names) # Reverse relation + self.assertIn('tags', field_names) # Tags + + field_names = get_prefetchable_fields(Circuit) + self.assertIn('group_assignments', field_names) # Generic relation