refactor(core): Update Tests to cater for inheritence changes
ref: #871 #861
This commit is contained in:
@ -260,11 +260,11 @@ class TicketBaseMetadataInheritedCases(
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.url_kwargs = {
|
self.url_kwargs = {
|
||||||
'ticket_model': self.model._meta.sub_model_type
|
'model_name': self.model._meta.sub_model_type
|
||||||
}
|
}
|
||||||
|
|
||||||
self.url_view_kwargs = {
|
self.url_view_kwargs = {
|
||||||
'ticket_model': self.model._meta.sub_model_type
|
'model_name': self.model._meta.sub_model_type
|
||||||
}
|
}
|
||||||
|
|
||||||
super().setUpTestData()
|
super().setUpTestData()
|
||||||
|
@ -103,11 +103,11 @@ class TicketBasePermissionsAPIInheritedCases(
|
|||||||
def inherited_var_setup(self, request):
|
def inherited_var_setup(self, request):
|
||||||
|
|
||||||
request.cls.url_kwargs.update({
|
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({
|
request.cls.url_view_kwargs.update({
|
||||||
'ticket_model': self.model._meta.sub_model_type
|
'model_name': self.model._meta.sub_model_type
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -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:
|
if self.add_data is not None:
|
||||||
|
|
||||||
@ -267,11 +267,11 @@ class TicketBaseViewSetInheritedCases(
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.url_kwargs = {
|
self.url_kwargs = {
|
||||||
'ticket_model': self.model._meta.model_name
|
'model_name': self.model._meta.model_name
|
||||||
}
|
}
|
||||||
|
|
||||||
self.url_view_kwargs = {
|
self.url_view_kwargs = {
|
||||||
'ticket_model': self.model._meta.model_name
|
'model_name': self.model._meta.model_name
|
||||||
}
|
}
|
||||||
|
|
||||||
super().setUpTestData()
|
super().setUpTestData()
|
||||||
|
@ -70,7 +70,7 @@ class APITestCases(
|
|||||||
if request.cls.model._meta.model_name != 'ticketbase':
|
if request.cls.model._meta.model_name != 'ticketbase':
|
||||||
|
|
||||||
request.cls.url_view_kwargs.update({
|
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
|
yield
|
||||||
@ -87,9 +87,9 @@ class APITestCases(
|
|||||||
|
|
||||||
request.cls.kwargs_create_item['category'].delete()
|
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']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class ViewsetTestCases(
|
|||||||
if self.model != TicketBase:
|
if self.model != TicketBase:
|
||||||
|
|
||||||
self.kwargs = {
|
self.kwargs = {
|
||||||
'ticket_model': self.model._meta.sub_model_type
|
'model_name': self.model._meta.model_name
|
||||||
}
|
}
|
||||||
|
|
||||||
self.viewset.kwargs = self.kwargs
|
self.viewset.kwargs = self.kwargs
|
||||||
@ -73,7 +73,7 @@ class ViewsetTestCases(
|
|||||||
|
|
||||||
view_set = self.viewset()
|
view_set = self.viewset()
|
||||||
|
|
||||||
assert view_set.model_kwarg == 'ticket_model'
|
assert view_set.model_kwarg == 'model_name'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ for model in apps.get_models():
|
|||||||
|
|
||||||
if issubclass(model, ticket.TicketBase):
|
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):
|
if issubclass(model, ticket_comment.TicketCommentBase):
|
||||||
|
@ -53,7 +53,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
|
|||||||
description='.',
|
description='.',
|
||||||
parameters = [
|
parameters = [
|
||||||
OpenApiParameter(
|
OpenApiParameter(
|
||||||
name = 'ticket_model',
|
name = 'model_name',
|
||||||
description = 'Enter the Ticket type. This is the name of the Ticket sub-model.',
|
description = 'Enter the Ticket type. This is the name of the Ticket sub-model.',
|
||||||
location = OpenApiParameter.PATH,
|
location = OpenApiParameter.PATH,
|
||||||
type = str,
|
type = str,
|
||||||
@ -94,7 +94,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
|
|||||||
description = '.',
|
description = '.',
|
||||||
parameters =[
|
parameters =[
|
||||||
OpenApiParameter(
|
OpenApiParameter(
|
||||||
name = 'ticket_model',
|
name = 'model_name',
|
||||||
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
|
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
|
||||||
location = OpenApiParameter.PATH,
|
location = OpenApiParameter.PATH,
|
||||||
type = str,
|
type = str,
|
||||||
@ -118,7 +118,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
|
|||||||
description='.',
|
description='.',
|
||||||
parameters = [
|
parameters = [
|
||||||
OpenApiParameter(
|
OpenApiParameter(
|
||||||
name = 'ticket_model',
|
name = 'model_name',
|
||||||
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
|
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
|
||||||
location = OpenApiParameter.PATH,
|
location = OpenApiParameter.PATH,
|
||||||
type = str,
|
type = str,
|
||||||
@ -150,7 +150,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
|
|||||||
description='.',
|
description='.',
|
||||||
parameters = [
|
parameters = [
|
||||||
OpenApiParameter(
|
OpenApiParameter(
|
||||||
name = 'ticket_model',
|
name = 'model_name',
|
||||||
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
|
description = 'Enter the ticket type. This is the name of the Ticket sub-model.',
|
||||||
location = OpenApiParameter.PATH,
|
location = OpenApiParameter.PATH,
|
||||||
type = str,
|
type = str,
|
||||||
@ -238,7 +238,7 @@ class ViewSet( SubModelViewSet ):
|
|||||||
'is_deleted'
|
'is_deleted'
|
||||||
]
|
]
|
||||||
|
|
||||||
model_kwarg = 'ticket_model'
|
model_kwarg = 'model_name'
|
||||||
|
|
||||||
search_fields = [
|
search_fields = [
|
||||||
'title',
|
'title',
|
||||||
@ -260,7 +260,7 @@ class ViewSet( SubModelViewSet ):
|
|||||||
viewname = '_api_ticket_sub-list',
|
viewname = '_api_ticket_sub-list',
|
||||||
request = self.request,
|
request = self.request,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'ticket_model': self.kwargs[self.model_kwarg],
|
'model_name': self.kwargs[self.model_kwarg],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user