From d8d665ecd9ee958abd898aff84d65a557d702ca5 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 13 May 2024 19:53:16 -0400 Subject: [PATCH] Update tests --- netbox/netbox/tests/test_plugins.py | 4 +++- netbox/utilities/testing/api.py | 4 ++-- netbox/utilities/testing/views.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/netbox/netbox/tests/test_plugins.py b/netbox/netbox/tests/test_plugins.py index 24bc53005..9ce20e204 100644 --- a/netbox/netbox/tests/test_plugins.py +++ b/netbox/netbox/tests/test_plugins.py @@ -42,6 +42,7 @@ class PluginTest(TestCase): url = reverse('admin:dummy_plugin_dummymodel_add') self.assertEqual(url, '/admin/dummy_plugin/dummymodel/add/') + @override_settings(LOGIN_REQUIRED=False) def test_views(self): # Test URL resolution @@ -53,7 +54,7 @@ class PluginTest(TestCase): response = client.get(url) self.assertEqual(response.status_code, 200) - @override_settings(EXEMPT_VIEW_PERMISSIONS=['*']) + @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], LOGIN_REQUIRED=False) def test_api_views(self): # Test URL resolution @@ -65,6 +66,7 @@ class PluginTest(TestCase): response = client.get(url) self.assertEqual(response.status_code, 200) + @override_settings(LOGIN_REQUIRED=False) def test_registered_views(self): # Test URL resolution diff --git a/netbox/utilities/testing/api.py b/netbox/utilities/testing/api.py index 563bd84b5..019d6e6ca 100644 --- a/netbox/utilities/testing/api.py +++ b/netbox/utilities/testing/api.py @@ -73,7 +73,7 @@ class APIViewTestCases: class GetObjectViewTestCase(APITestCase): - @override_settings(EXEMPT_VIEW_PERMISSIONS=['*']) + @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], LOGIN_REQUIRED=False) def test_get_object_anonymous(self): """ GET a single object as an unauthenticated user. @@ -135,7 +135,7 @@ class APIViewTestCases: class ListObjectsViewTestCase(APITestCase): brief_fields = [] - @override_settings(EXEMPT_VIEW_PERMISSIONS=['*']) + @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], LOGIN_REQUIRED=False) def test_list_objects_anonymous(self): """ GET a list of objects as an unauthenticated user. diff --git a/netbox/utilities/testing/views.py b/netbox/utilities/testing/views.py index e3b12b4c3..6d4ca00df 100644 --- a/netbox/utilities/testing/views.py +++ b/netbox/utilities/testing/views.py @@ -62,7 +62,7 @@ class ViewTestCases: """ Retrieve a single instance. """ - @override_settings(EXEMPT_VIEW_PERMISSIONS=['*']) + @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], LOGIN_REQUIRED=False) def test_get_object_anonymous(self): # Make the request as an unauthenticated user self.client.logout() @@ -421,7 +421,7 @@ class ViewTestCases: """ Retrieve multiple instances. """ - @override_settings(EXEMPT_VIEW_PERMISSIONS=['*']) + @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], LOGIN_REQUIRED=False) def test_list_objects_anonymous(self): # Make the request as an unauthenticated user self.client.logout()