test: correct viewset tests

ref: #741
This commit is contained in:
2025-05-06 00:48:29 +09:30
parent 88a30650a5
commit 5ba243a1ea
5 changed files with 69 additions and 20 deletions

View File

@ -17,9 +17,7 @@ class ViewsetTestCases(
SubModelViewSetInheritedCases,
):
model = TicketBase
kwargs = None
model = None
viewset = ViewSet
@ -36,8 +34,21 @@ class ViewsetTestCases(
"""
if self.model is None:
self.model = TicketBase
super().setUpTestData()
if self.model != TicketBase:
self.kwargs = {
'ticket_model': self.model._meta.sub_model_type
}
self.viewset.kwargs = self.kwargs
client = Client()
@ -79,24 +90,11 @@ class TicketBaseViewsetInheritedCases(
@classmethod
def setUpTestData(self):
self.kwargs = {
'ticket_model': self.model._meta.sub_model_type
}
super().setUpTestData()
class TicketBaseViewsetTest(
ViewsetTestCases,
TestCase,
):
kwargs = {}
route_name = 'v2:_api_v2_ticket'
viewset = NoDocsViewSet