From bc329d2453442d9441aa8e849e96c3e568644860 Mon Sep 17 00:00:00 2001 From: Jon Date: Sat, 8 Feb 2025 23:05:48 +0930 Subject: [PATCH] test(itim): Cluster Types Notes Function Viewset Tests ref: #525 #535 --- ..._functional_cluster_types_notes_viewset.py | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 app/itim/tests/functional/cluster_types_notes/test_functional_cluster_types_notes_viewset.py diff --git a/app/itim/tests/functional/cluster_types_notes/test_functional_cluster_types_notes_viewset.py b/app/itim/tests/functional/cluster_types_notes/test_functional_cluster_types_notes_viewset.py new file mode 100644 index 00000000..9b9c92a4 --- /dev/null +++ b/app/itim/tests/functional/cluster_types_notes/test_functional_cluster_types_notes_viewset.py @@ -0,0 +1,125 @@ +from django.contrib.contenttypes.models import ContentType +from django.test import TestCase + +from core.tests.abstract.test_functional_notes_viewset import ( + ModelNotesViewSetBase, + ModelNotesMetadata, + ModelNotesPermissionsAPI, + ModelNotesSerializer +) + +from itim.viewsets.cluster_type_notes import ViewSet + + + +class ViewSetBase( + ModelNotesViewSetBase +): + + viewset = ViewSet + + url_name = '_api_v2_cluster_type_note' + + @classmethod + def setUpTestData(self): + + + super().setUpTestData() + + self.item = self.viewset.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 = self.viewset.model.model.field.related_model.objects.create( + organization = self.organization, + name = 'note model', + ), + created_by = self.view_user, + modified_by = self.view_user, + ) + + self.other_org_item = self.viewset.model.objects.create( + organization = self.different_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 = self.viewset.model.model.field.related_model.objects.create( + organization = self.different_organization, + name = 'note model other_org_item', + ), + created_by = self.view_user, + modified_by = self.view_user, + ) + + + self.global_org_item = self.viewset.model.objects.create( + organization = self.global_organization, + content = 'a random comment global_organization', + 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 = self.viewset.model.model.field.related_model.objects.create( + organization = self.global_organization, + name = 'note model global_organization', + ), + created_by = self.view_user, + modified_by = self.view_user, + ) + + self.url_kwargs = { + 'model_id': self.item.model.pk, + } + + self.url_view_kwargs = { + 'model_id': self.item.model.pk, + 'pk': self.item.id + } + + + +class ClusterTypeModelNotesPermissionsAPI( + ViewSetBase, + ModelNotesPermissionsAPI, + TestCase, +): + + + def test_returned_data_from_user_and_global_organizations_only(self): + """Check items returned + + This test case is a over-ride of a test case with the same name. + This model is not a global model making this test not-applicable. + + Items returned from the query Must be from the users organization and + global ONLY! + """ + pass + + + + + +class ClusterTypeBaseModelNotesSerializer( + ViewSetBase, + ModelNotesSerializer, + TestCase, +): + + pass + + + +class ClusterTypeModelNotesMetadata( + ViewSetBase, + ModelNotesMetadata, + TestCase, + +): + + pass