From b4cf85149bb7bb36dcda53ad620921bdfba2cd74 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 22 Jul 2020 11:51:41 -0400 Subject: [PATCH] Add tests for users and groups API endpoints --- netbox/users/tests/test_api.py | 56 +++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/netbox/users/tests/test_api.py b/netbox/users/tests/test_api.py index 757b186cc..42c5a3e03 100644 --- a/netbox/users/tests/test_api.py +++ b/netbox/users/tests/test_api.py @@ -18,9 +18,63 @@ class AppTest(APITestCase): self.assertEqual(response.status_code, 200) +class UserTest(APIViewTestCases.APIViewTestCase): + model = User + view_namespace = 'users' + brief_fields = ['id', 'url', 'username'] + create_data = [ + { + 'username': 'User_4', + }, + { + 'username': 'User_5', + }, + { + 'username': 'User_6', + }, + ] + + @classmethod + def setUpTestData(cls): + + users = ( + User(username='User_1'), + User(username='User_2'), + User(username='User_3'), + ) + User.objects.bulk_create(users) + + +class GroupTest(APIViewTestCases.APIViewTestCase): + model = Group + view_namespace = 'users' + brief_fields = ['id', 'name', 'url'] + create_data = [ + { + 'name': 'Group 4', + }, + { + 'name': 'Group 5', + }, + { + 'name': 'Group 6', + }, + ] + + @classmethod + def setUpTestData(cls): + + users = ( + Group(name='Group 1'), + Group(name='Group 2'), + Group(name='Group 3'), + ) + Group.objects.bulk_create(users) + + class ObjectPermissionTest(APIViewTestCases.APIViewTestCase): model = ObjectPermission - brief_fields = ['actions', 'enabled', 'groups', 'id', 'name', 'object_types', 'users'] + brief_fields = ['actions', 'enabled', 'groups', 'id', 'name', 'object_types', 'url', 'users'] @classmethod def setUpTestData(cls):