From a081c6a3715ada187f02b907d3cd23e95ba05189 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 9 May 2025 21:05:54 +0930 Subject: [PATCH] test(core): Partial Functional Model test cases (Slash Commands) for TicketCommentBase ref: #744 #726 --- .../ticket_comment_base/conftest.py | 14 +++ ...st_functional_ticket_comment_base_model.py | 85 +++++++++++++++++++ .../centurion_erp/development/core/ticket.md | 2 + 3 files changed, 101 insertions(+) create mode 100644 app/core/tests/functional/ticket_comment_base/conftest.py create mode 100644 app/core/tests/functional/ticket_comment_base/test_functional_ticket_comment_base_model.py diff --git a/app/core/tests/functional/ticket_comment_base/conftest.py b/app/core/tests/functional/ticket_comment_base/conftest.py new file mode 100644 index 00000000..daaa25be --- /dev/null +++ b/app/core/tests/functional/ticket_comment_base/conftest.py @@ -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 diff --git a/app/core/tests/functional/ticket_comment_base/test_functional_ticket_comment_base_model.py b/app/core/tests/functional/ticket_comment_base/test_functional_ticket_comment_base_model.py new file mode 100644 index 00000000..d94ef273 --- /dev/null +++ b/app/core/tests/functional/ticket_comment_base/test_functional_ticket_comment_base_model.py @@ -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 diff --git a/docs/projects/centurion_erp/development/core/ticket.md b/docs/projects/centurion_erp/development/core/ticket.md index 83b2b4ed..9e1fcf38 100644 --- a/docs/projects/centurion_erp/development/core/ticket.md +++ b/docs/projects/centurion_erp/development/core/ticket.md @@ -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` + - 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.