refactor(core): Update Test Suite for TicketCommentAction model
ref: #871 #864
This commit is contained in:
@ -6,6 +6,8 @@ class TicketCommentAction(
|
||||
TicketCommentBase,
|
||||
):
|
||||
|
||||
_is_submodel = True
|
||||
|
||||
class Meta:
|
||||
|
||||
ordering = [
|
||||
@ -28,24 +30,3 @@ class TicketCommentAction(
|
||||
self.is_closed = True
|
||||
|
||||
super().clean()
|
||||
|
||||
|
||||
|
||||
# def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||
|
||||
# super().save(force_insert = force_insert, force_update = force_update, using = using, update_fields = update_fields)
|
||||
|
||||
# self.ticket.is_solved =
|
||||
|
||||
# self.ticket.date_solved = self.date_closed
|
||||
|
||||
# self.ticket.status = self.ticket.TicketStatus.SOLVED
|
||||
|
||||
# self.ticket.save()
|
||||
|
||||
# # clear comment cache
|
||||
# if hasattr(self.ticket, '_ticket_comments'):
|
||||
|
||||
# del self.ticket._ticket_comments
|
||||
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from core.tests.functional.ticket_comment_base.test_functional_ticket_comment_base_model import TicketCommentBaseModelInheritedTestCases
|
||||
|
||||
|
||||
@pytest.mark.model_ticketcommentaction
|
||||
class TicketCommentActionModelTestCases(
|
||||
TicketCommentBaseModelInheritedTestCases
|
||||
):
|
||||
@ -19,6 +22,7 @@ class TicketCommentActionModelInheritedTestCases(
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_core
|
||||
class TicketCommentActionModelPyTest(
|
||||
TicketCommentActionModelTestCases
|
||||
):
|
||||
|
@ -1,14 +1,20 @@
|
||||
import pytest
|
||||
|
||||
from core.models.ticket_comment_action import TicketCommentAction
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model(request):
|
||||
def model(request, model_ticketcommentaction):
|
||||
|
||||
request.cls.model = TicketCommentAction
|
||||
request.cls.model = model_ticketcommentaction
|
||||
|
||||
yield request.cls.model
|
||||
|
||||
del request.cls.model
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class', autouse = True)
|
||||
def model_kwargs(request, kwargs_ticketcommentaction):
|
||||
|
||||
request.cls.kwargs_create_item = kwargs_ticketcommentaction.copy()
|
||||
|
||||
yield kwargs_ticketcommentaction.copy()
|
||||
|
@ -1,9 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from core.tests.unit.ticket_comment_base.test_unit_ticket_comment_base_api_fields import (
|
||||
TicketCommentBaseAPIInheritedCases
|
||||
)
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_ticketcommentaction
|
||||
class TicketCommentActionAPITestCases(
|
||||
TicketCommentBaseAPIInheritedCases,
|
||||
):
|
||||
@ -24,6 +27,7 @@ class TicketCommentActionAPIInheritedCases(
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_core
|
||||
class TicketCommentActionAPIPyTest(
|
||||
TicketCommentActionAPITestCases,
|
||||
):
|
||||
|
@ -1,40 +1,65 @@
|
||||
from rest_framework.exceptions import ValidationError
|
||||
import pytest
|
||||
|
||||
from core.models.ticket_comment_action import TicketCommentAction
|
||||
|
||||
from core.tests.unit.ticket_comment_base.test_unit_ticket_comment_base_model import (
|
||||
TicketCommentBaseModelInheritedCases
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_ticketcommentaction
|
||||
class TicketCommentActionModelTestCases(
|
||||
TicketCommentBaseModelInheritedCases,
|
||||
TicketCommentBaseModelInheritedCases
|
||||
):
|
||||
|
||||
sub_model_type = 'action'
|
||||
"""Sub Model Type
|
||||
|
||||
sub-models must have this attribute defined in `ModelName.Meta.sub_model_type`
|
||||
"""
|
||||
|
||||
kwargs_create_item: dict = {
|
||||
'comment_type': sub_model_type,
|
||||
}
|
||||
@property
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {
|
||||
'_audit_enabled': {
|
||||
'value': False
|
||||
},
|
||||
'_is_submodel': {
|
||||
'value': True
|
||||
},
|
||||
'_notes_enabled': {
|
||||
'value': False
|
||||
},
|
||||
'model_tag': {
|
||||
'type': type(None),
|
||||
'value': None
|
||||
},
|
||||
'url_model_name': {
|
||||
'type': str,
|
||||
'value': 'ticket_comment_base'
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def test_class_inherits_ticketcommentaction(self):
|
||||
@property
|
||||
def parameterized_model_fields(self):
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
|
||||
def test_class_inherits_TicketCommentAction(self, model):
|
||||
""" Class inheritence
|
||||
|
||||
TenancyObject must inherit SaveHistory
|
||||
"""
|
||||
|
||||
assert issubclass(self.model, TicketCommentAction)
|
||||
assert issubclass(model, TicketCommentAction)
|
||||
|
||||
|
||||
|
||||
def test_function_called_clean_ticketcommentaction(self, model, mocker, ticket):
|
||||
"""Function Check
|
||||
|
||||
Ensure function `TicketCommentBase.clean` is called
|
||||
Ensure function `TicketCommentAction.clean` is called
|
||||
"""
|
||||
|
||||
spy = mocker.spy(TicketCommentAction, 'clean')
|
||||
@ -43,9 +68,6 @@ class TicketCommentActionModelTestCases(
|
||||
|
||||
valid_data['ticket'] = ticket
|
||||
|
||||
del valid_data['external_system']
|
||||
del valid_data['external_ref']
|
||||
|
||||
comment = model.objects.create(
|
||||
**valid_data
|
||||
)
|
||||
@ -81,31 +103,17 @@ class TicketCommentActionModelTestCases(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TicketCommentActionModelInheritedCases(
|
||||
TicketCommentActionModelTestCases,
|
||||
):
|
||||
"""Sub-Ticket Test Cases
|
||||
|
||||
Test Cases for Ticket models that inherit from model TicketCommentAction
|
||||
"""
|
||||
|
||||
kwargs_create_item: dict = {}
|
||||
|
||||
model = None
|
||||
|
||||
|
||||
sub_model_type = None
|
||||
"""Ticket Sub Model Type
|
||||
|
||||
Ticket sub-models must have this attribute defined in `ModelNam.Meta.sub_model_type`
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_core
|
||||
class TicketCommentActionModelPyTest(
|
||||
TicketCommentActionModelTestCases,
|
||||
):
|
||||
|
||||
pass
|
||||
sub_model_type = 'action'
|
||||
|
@ -1,3 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from core.models.ticket_comment_action import TicketCommentAction
|
||||
@ -5,6 +7,7 @@ from core.tests.unit.ticket_comment_base.test_unit_ticket_comment_base_viewset i
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_ticketcommentaction
|
||||
class TicketCommentActionViewsetTestCases(
|
||||
TicketCommentBaseViewsetInheritedCases,
|
||||
):
|
||||
@ -32,6 +35,7 @@ class TicketCommentActionViewsetInheritedCases(
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_core
|
||||
class TicketCommentActionViewsetTest(
|
||||
TicketCommentActionViewsetTestCases,
|
||||
TestCase,
|
||||
|
5
app/tests/fixtures/__init__.py
vendored
5
app/tests/fixtures/__init__.py
vendored
@ -278,6 +278,11 @@ from .model_ticketbase import (
|
||||
model_ticketbase,
|
||||
)
|
||||
|
||||
from .model_ticketcommentaction import (
|
||||
kwargs_ticketcommentaction,
|
||||
model_ticketcommentaction,
|
||||
)
|
||||
|
||||
from .model_ticketcommentbase import (
|
||||
kwargs_ticketcommentbase,
|
||||
model_ticketcommentbase,
|
||||
|
23
app/tests/fixtures/model_ticketcommentaction.py
vendored
Normal file
23
app/tests/fixtures/model_ticketcommentaction.py
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
|
||||
from core.models.ticket_comment_action import TicketCommentAction
|
||||
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def model_ticketcommentaction():
|
||||
|
||||
yield TicketCommentAction
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'class')
|
||||
def kwargs_ticketcommentaction(
|
||||
model_ticketcommentaction, kwargs_ticketcommentbase,
|
||||
):
|
||||
|
||||
kwargs = {
|
||||
**kwargs_ticketcommentbase,
|
||||
'comment_type': model_ticketcommentaction._meta.sub_model_type,
|
||||
}
|
||||
|
||||
yield kwargs.copy()
|
@ -1147,6 +1147,7 @@ markers = [
|
||||
"model_softwareversion: Selects tests for model Software Version.",
|
||||
"model_ticketbase: Selects tests for model Ticket Base.",
|
||||
"model_ticketcategory: Select all ticket category tests.",
|
||||
"model_ticketcommentaction: Select test for model ticket Action Comment.",
|
||||
"model_ticketcommentbase: Select all ticket Comment.",
|
||||
"model_ticketcommentcategory: Select all ticket comment category tests.",
|
||||
"models: Selects all models tests.",
|
||||
|
Reference in New Issue
Block a user