diff --git a/app/itim/tests/unit/port_notes/test_unit_port_notes_viewset.py b/app/itim/tests/unit/port_notes/test_unit_port_notes_viewset.py new file mode 100644 index 00000000..8be34c3c --- /dev/null +++ b/app/itim/tests/unit/port_notes/test_unit_port_notes_viewset.py @@ -0,0 +1,77 @@ +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.port_notes import ViewSet + + +class ViewsetCommon( + ViewSetModel, +): + + viewset = ViewSet + + route_name = 'v2:_api_v2_port_note' + + @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) + + + + +class PortNotesViewsetList( + ViewsetCommon, + TestCase, +): + + + @classmethod + def setUpTestData(self): + """Setup Test + + 1. Create object that is to be tested against + 2. add kwargs + 3. make list request + """ + + + super().setUpTestData() + + self.note_model = self.viewset.model.model.field.related_model.objects.create( + organization = self.organization, + number = 55, + ) + + self.kwargs = { + 'model_id': self.note_model.pk, + } + + + 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)