test(assistance): KB Test Cases for API Field Checks

ref: #525 #528
This commit is contained in:
2025-02-08 17:24:07 +09:30
parent e7729afc98
commit bff5ea3fe8
2 changed files with 57 additions and 2 deletions

View File

@ -17,9 +17,9 @@ class KnowledgeBaseNotes(
ordering = ModelNotes._meta.ordering
verbose_name = 'Knowledge Base Article Note'
verbose_name = 'Knowledge Base Note'
verbose_name_plural = 'Knowledge Base Article Notes'
verbose_name_plural = 'Knowledge Base Notes'
model = models.ForeignKey(

View File

@ -0,0 +1,55 @@
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from core.tests.abstract.model_notes_api_fields import ModelNotesNotesAPIFields
from assistance.models.knowledge_base_notes import KnowledgeBase, KnowledgeBaseNotes
class KnowledgeBaseNotesAPI(
ModelNotesNotesAPIFields,
TestCase,
):
model = KnowledgeBaseNotes
view_name: str = '_api_v2_knowledge_base_note'
@classmethod
def setUpTestData(self):
"""Setup Test
1. Call parent setup
2. Create a model note
3. add url kwargs
4. make the API request
"""
super().setUpTestData()
self.item = self.model.objects.create(
organization = self.organization,
content = 'a random comment',
content_type = ContentType.objects.get(
app_label = str(self.model._meta.app_label).lower(),
model = str(self.model.model.field.related_model.__name__).replace(' ', '').lower(),
),
model = KnowledgeBase.objects.create(
organization = self.organization,
title = 'note model',
content = 'text'
),
created_by = self.view_user,
modified_by = self.view_user,
)
self.url_view_kwargs = {
'model_id': self.item.model.pk,
'pk': self.item.pk
}
self.make_request()