test(core): Partial Functional Model test cases (Slash Commands) for TicketCommentBase

ref: #744 #726
This commit is contained in:
2025-05-09 21:05:54 +09:30
parent 6c3122a3d8
commit a081c6a371
3 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,14 @@
import pytest
from core.models.ticket_comment_base import TicketCommentBase
@pytest.fixture( scope = 'class')
def model(request):
request.cls.model = TicketCommentBase
yield request.cls.model
del request.cls.model

View File

@ -0,0 +1,85 @@
import pytest
from core.models.ticket.ticket import Ticket
from core.tests.functional.slash_commands.test_slash_command_related import SlashCommandsTicketCommentInheritedTestCases
class TicketCommentBaseModelTestCases(
SlashCommandsTicketCommentInheritedTestCases
):
@pytest.fixture
def ticket(self, request, django_db_blocker):
""" Ticket that requires body
when using this fixture, set the `description` then call ticket.save()
before use.
"""
from core.models.ticket_comment_base import TicketBase
with django_db_blocker.unblock():
ticket = TicketBase()
ticket.organization = request.cls.organization
ticket.title = 'A ticket for slash commands'
ticket.opened_by = request.cls.ticket_user
ticket = TicketBase.objects.create(
organization = request.cls.organization,
title = 'A ticket for slash commands',
opened_by = request.cls.ticket_user,
)
yield ticket
with django_db_blocker.unblock():
ticket.delete()
@pytest.fixture
def ticket_comment(self, request, django_db_blocker, ticket, model):
""" Ticket Comment that requires body
when using this fixture, set the `body` then call ticket_comment.save()
before use.
"""
with django_db_blocker.unblock():
ticket.title = 'slash command ticket with comment'
ticket.save()
ticket_comment = model()
ticket_comment.user = request.cls.entity_user
ticket_comment.ticket = ticket
ticket_comment.comment_type = 'comment'
yield ticket_comment
ticket_comment.delete()
class TicketCommentBaseModelInheritedTestCases(
TicketCommentBaseModelTestCases
):
pass
class TicketCommentBaseModelPyTest(
TicketCommentBaseModelTestCases
):
pass

View File

@ -40,4 +40,6 @@ As with any other object within Centurion, the addition of a feature requires it
- API Permissions `core.tests.functional.ticket_base.test_functional_ticket_base_permission.TicketBasePermissionsAPIInheritedCases` - API Permissions `core.tests.functional.ticket_base.test_functional_ticket_base_permission.TicketBasePermissionsAPIInheritedCases`
- Model `app.core.tests.functional.ticket_base.test_functional_ticket_base_model.TicketBaseModelInheritedTestCases` _(if inheriting from `TicketBase`)_ Test cases for sub-models
The above listed test cases cover **all** tests for objects that are inherited from the base class. To complete the tests, you will need to add test cases for the differences your model introduces. The above listed test cases cover **all** tests for objects that are inherited from the base class. To complete the tests, you will need to add test cases for the differences your model introduces.