test(itim): Service Note API ViewSet permission checks

ref: #15 #49 #248 #354
This commit is contained in:
2024-10-18 18:27:14 +09:30
parent 3e210ed217
commit df5a185986
3 changed files with 124 additions and 3 deletions

View File

@ -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 itim.models.services import Service
class ServiceNotePermissionsAPI(
NoteViewSetCommon,
TestCase,
):
app_namespace = 'API'
url_name = '_api_v2_service_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 = Service.objects.create(
organization = self.organization,
name = 'history-device'
)
self.item = Notes.objects.create(
organization = self.organization,
note = 'a note',
usercreated = self.view_user,
service = self.note_item
)
self.url_kwargs = {'service_id': self.note_item.id}
self.url_view_kwargs = {'service_id': self.note_item.id, 'pk': self.item.pk }
self.add_data = {'note': 'a note added', 'organization': self.organization.id}