Skip to content

Commit

Permalink
[FIX] helpdesk_mgmt_templates: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dessanhemrayev committed Aug 9, 2024
1 parent d2a93f2 commit 32608c2
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions helpdesk_mgmt_templates/tests/test_helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ def setUpClass(cls):
cls.category_2 = helpdesk_ticket_category_obj.create(
{"name": "Category 2", "template_description": "<h2>Description 2</h2>"}
)
cls.category_3 = helpdesk_ticket_category_obj.create(
{"name": "Category 3", "template_description": "<h3>Description 3</h3>"}
)
helpdesk_ticket_team = cls.env["helpdesk.ticket.team"]

cls.team_c = helpdesk_ticket_team.create(
{
"name": "Team C",
"user_ids": [(6, 0, [cls.user_team.id])],
"category_ids": [(6, 0, [cls.category_1.id, cls.category_3.id])],
}
)

def test_set_category(self):
"""
Expand Down Expand Up @@ -59,3 +71,59 @@ def test_set_category(self):
" to the template_description of Category 1"
),
)

def test_check_available_team_categories(self):
"""
Test the availability of team categories and
their correct linking to the team and ticket.
"""
# Check that initially, a team should not have categories attached to it.
self.assertFalse(
self.ticket_a_user_own.helpdesk_ticket_category_ids,
msg="A team should not have categories attached to it.",
)

# Assign a team to the ticket and check that the categories are linked to the team.
self.ticket_a_user_own.team_id = self.team_c.id
related_category_ids = [self.category_1.id, self.category_3.id]
self.assertEqual(
self.ticket_a_user_own.helpdesk_ticket_category_ids.ids,
related_category_ids,
msg="Categories should be linked to the team.",
)

# Set the category_id of the ticket to the first category in the linked categories.
self.ticket_a_user_own.category_id = (
self.ticket_a_user_own.helpdesk_ticket_category_ids[0]
)

# Check that the category_id has been correctly set.
self.assertEqual(
self.ticket_a_user_own.category_id.id,
self.category_1.id,
msg=f"The category ID #{self.category_1.id} was not correctly set",
)

def test_create_ticket_with_category(self):
"""
Test the creation of a ticket with a specific category and
verify that the category is correctly set.
"""
# Create a ticket with a specific category
ticket = self.env["helpdesk.ticket"].create(
{
"name": f"Ticket {self.team_c.name} (test)",
"team_id": self.team_c.id,
"user_id": False,
"description": "Test",
"category_id": self.category_1.id,
"priority": "1",
}
)

# Check that the category_id has been correctly set
self.assertEqual(
ticket.category_id.id,
self.category_1.id,
msg=f"The category ID #{self.category_1.id} was not correctly set",
)

0 comments on commit 32608c2

Please sign in to comment.