From 29443a51fca7f0bc25d8945f9407f684045b3b2a Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 6 Feb 2025 20:44:20 +0930 Subject: [PATCH] test(itim): Add missing unit tests for incident ticket viewset ref: #512 #513 #518 --- .../test_unit_ticket_incident_viewset.py | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 app/itim/tests/unit/ticket_incident/test_unit_ticket_incident_viewset.py diff --git a/app/itim/tests/unit/ticket_incident/test_unit_ticket_incident_viewset.py b/app/itim/tests/unit/ticket_incident/test_unit_ticket_incident_viewset.py new file mode 100644 index 00000000..d2166d5d --- /dev/null +++ b/app/itim/tests/unit/ticket_incident/test_unit_ticket_incident_viewset.py @@ -0,0 +1,69 @@ +import pytest + +from django.contrib.auth.models import User +from django.test import Client, TestCase + +from rest_framework.reverse import reverse + +from access.models import Organization + +from api.tests.abstract.viewsets import ViewSetModel + +from itim.viewsets.incident import ViewSet + + + + +class ViewsetCommon( + ViewSetModel, +): + + viewset = ViewSet + + route_name = 'v2:_api_v2_ticket_incident' + + @classmethod + def setUpTestData(self): + """Setup Test + + 1. Create an organization + 3. create super user + """ + + organization = Organization.objects.create(name='test_org') + + self.organization = organization + + self.view_user = User.objects.create_user(username="test_view_user", password="password", is_superuser=True) + + self.kwargs = {} + + + +class IncidentTicketViewsetList( + ViewsetCommon, + TestCase, +): + + + @classmethod + def setUpTestData(self): + """Setup Test + + 1. make list request + """ + + + super().setUpTestData() + + + client = Client() + + url = reverse( + self.route_name + '-list', + kwargs = self.kwargs + ) + + client.force_login(self.view_user) + + self.http_options_response_list = client.options(url)