test(itim): Cluster Types Notes Test Cases for API Field Checks
ref: #525 #535
This commit is contained in:
@ -0,0 +1,54 @@
|
|||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from core.tests.abstract.model_notes_api_fields import ModelNotesNotesAPIFields
|
||||||
|
|
||||||
|
from itim.models.cluster_type_notes import ClusterType, ClusterTypeNotes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class ClusterTypeNotesAPI(
|
||||||
|
ModelNotesNotesAPIFields,
|
||||||
|
TestCase,
|
||||||
|
):
|
||||||
|
|
||||||
|
model = ClusterTypeNotes
|
||||||
|
|
||||||
|
view_name: str = '_api_v2_cluster_type_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 = ClusterType.objects.create(
|
||||||
|
organization = self.organization,
|
||||||
|
name = 'note model',
|
||||||
|
),
|
||||||
|
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()
|
Reference in New Issue
Block a user