From fd126f074269f93f945e81288e15eb0b3a1df1b3 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 18 Oct 2024 16:38:38 +0930 Subject: [PATCH] test(config_management): Config Groups Note API ViewSet permission checks ref: #15 #49 #248 #354 --- .../test_config_groups_notes_viewset.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/config_management/tests/unit/config_groups/test_config_groups_notes_viewset.py diff --git a/app/config_management/tests/unit/config_groups/test_config_groups_notes_viewset.py b/app/config_management/tests/unit/config_groups/test_config_groups_notes_viewset.py new file mode 100644 index 00000000..7a74f3dc --- /dev/null +++ b/app/config_management/tests/unit/config_groups/test_config_groups_notes_viewset.py @@ -0,0 +1,55 @@ +import pytest + +from django.test import TestCase + +from core.tests.abstract.test_notes_viewset import NoteViewSetCommon + +from core.models.notes import Notes + +from config_management.models.groups import ConfigGroups + + + +class NotePermissionsAPI( + NoteViewSetCommon, + TestCase, +): + + app_namespace = 'API' + + url_name = '_api_v2_config_group_notes' + + + @classmethod + def setUpTestData(self): + """Setup Test + + 1. Create an organization for user and item + . create an organization that is different to item + 2. Create a team + 3. create teams with each permission: view, add, change, delete + 4. create a user per team + """ + + super().setUpTestData() + + + + self.note_item = ConfigGroups.objects.create( + organization = self.organization, + name = 'history-device' + ) + + self.item = Notes.objects.create( + organization = self.organization, + note = 'a note', + usercreated = self.view_user, + config_group = self.note_item + ) + + + self.url_kwargs = {'group_id': self.note_item.id} + + self.url_view_kwargs = {'group_id': self.note_item.id, 'pk': self.item.pk } + + self.add_data = {'note': 'a note added', 'organization': self.organization.id}