refactor(core): Update Tests to cater for inheritence changes

ref: #871 #861
This commit is contained in:
2025-07-16 21:56:12 +09:30
parent 8cc8fdad8b
commit 27e842a57f
7 changed files with 19 additions and 19 deletions

View File

@ -260,11 +260,11 @@ class TicketBaseMetadataInheritedCases(
}
self.url_kwargs = {
'ticket_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
}
self.url_view_kwargs = {
'ticket_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
}
super().setUpTestData()

View File

@ -103,11 +103,11 @@ class TicketBasePermissionsAPIInheritedCases(
def inherited_var_setup(self, request):
request.cls.url_kwargs.update({
'ticket_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
})
request.cls.url_view_kwargs.update({
'ticket_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
})

View File

@ -93,7 +93,7 @@ class ViewSetBase:
)
self.url_view_kwargs.update({ 'pk': self.item.id })
self.url_view_kwargs.update({'model_name': self.item._meta.model_name, 'pk': self.item.id })
if self.add_data is not None:
@ -267,11 +267,11 @@ class TicketBaseViewSetInheritedCases(
}
self.url_kwargs = {
'ticket_model': self.model._meta.model_name
'model_name': self.model._meta.model_name
}
self.url_view_kwargs = {
'ticket_model': self.model._meta.model_name
'model_name': self.model._meta.model_name
}
super().setUpTestData()

View File

@ -70,7 +70,7 @@ class APITestCases(
if request.cls.model._meta.model_name != 'ticketbase':
request.cls.url_view_kwargs.update({
'ticket_model': str(request.cls.model._meta.sub_model_type),
'model_name': str(request.cls.model._meta.sub_model_type),
})
yield
@ -87,9 +87,9 @@ class APITestCases(
request.cls.kwargs_create_item['category'].delete()
if 'ticket_model' in request.cls.url_view_kwargs:
if 'model_name' in request.cls.url_view_kwargs:
del request.cls.url_view_kwargs['ticket_model']
del request.cls.url_view_kwargs['model_name']

View File

@ -45,7 +45,7 @@ class ViewsetTestCases(
if self.model != TicketBase:
self.kwargs = {
'ticket_model': self.model._meta.sub_model_type
'model_name': self.model._meta.model_name
}
self.viewset.kwargs = self.kwargs
@ -73,7 +73,7 @@ class ViewsetTestCases(
view_set = self.viewset()
assert view_set.model_kwarg == 'ticket_model'
assert view_set.model_kwarg == 'model_name'

View File

@ -21,7 +21,7 @@ for model in apps.get_models():
if issubclass(model, ticket.TicketBase):
ticket_type_names += model._meta.sub_model_type + '|'
ticket_type_names += model._meta.model_name + '|'
if issubclass(model, ticket_comment.TicketCommentBase):

View File

@ -53,7 +53,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description='.',
parameters = [
OpenApiParameter(
name = 'ticket_model',
name = 'model_name',
description = 'Enter the Ticket type. This is the name of the Ticket sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -94,7 +94,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description = '.',
parameters =[
OpenApiParameter(
name = 'ticket_model',
name = 'model_name',
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -118,7 +118,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description='.',
parameters = [
OpenApiParameter(
name = 'ticket_model',
name = 'model_name',
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -150,7 +150,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description='.',
parameters = [
OpenApiParameter(
name = 'ticket_model',
name = 'model_name',
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -238,7 +238,7 @@ class ViewSet( SubModelViewSet ):
'is_deleted'
]
model_kwarg = 'ticket_model'
model_kwarg = 'model_name'
search_fields = [
'title',
@ -260,7 +260,7 @@ class ViewSet( SubModelViewSet ):
viewname = '_api_ticket_sub-list',
request = self.request,
kwargs = {
'ticket_model': self.kwargs[self.model_kwarg],
'model_name': self.kwargs[self.model_kwarg],
}
)