-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] helpdesk_mgmt: Test access added
Forward port of dfbc369
- Loading branch information
1 parent
977fd29
commit 60bfad7
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import time | ||
|
||
from odoo.tests import tagged | ||
|
||
from .common import TestHelpdeskTicketBase | ||
|
||
|
||
|
@@ -173,3 +175,98 @@ def test_ticket_without_team(self): | |
} | ||
) | ||
self.assertEqual(self.new_stage, new_ticket.stage_id) | ||
|
||
def test_helpdesk_ticket_multiple(self): | ||
partner_1 = self.Partner.create( | ||
{"name": "Partner 1", "email": "[email protected]"} | ||
) | ||
partner_2 = self.Partner.create( | ||
{"name": "Partner 2", "email": "[email protected]"} | ||
) | ||
tickets = self.Ticket.create( | ||
[ | ||
{ | ||
"name": "Test 1", | ||
"description": "Ticket test number 1", | ||
"user_id": self.user.id, | ||
"partner_email": "[email protected]", | ||
}, | ||
{ | ||
"name": "Test 2", | ||
"description": "Ticket test number 2", | ||
"user_id": self.user.id, | ||
"partner_id": partner_1.id, | ||
}, | ||
{ | ||
"name": "Test 3", | ||
"description": "Ticket test number 3", | ||
"user_id": self.user_demo.id, | ||
"partner_id": partner_2.id, | ||
}, | ||
] | ||
) | ||
self.assertEqual(len(tickets), 3) | ||
|
||
def test_helpdesk_ticket_access(self): | ||
t = self.Ticket.create( | ||
{ | ||
"name": "Test 1", | ||
"description": "Ticket test", | ||
} | ||
) | ||
self.assertEqual(t.access_url, "/my/ticket/%s" % t.id) | ||
t.partner_id = self.user_portal.partner_id.id | ||
self.assertTrue(t.partner_can_access()) | ||
|
||
def test_partner_can_access(self): | ||
p = self.env.ref("base.res_partner_1") | ||
t = self.Ticket.create( | ||
{ | ||
"name": "Test 1", | ||
"description": "Ticket test", | ||
"partner_id": p.id, | ||
} | ||
) | ||
self.assertFalse(t.partner_can_access()) | ||
t.partner_id = self.env.ref("base.user_admin").partner_id.id | ||
self.assertTrue(t.partner_can_access()) | ||
|
||
def test_access_url(self): | ||
t = self.Ticket.create( | ||
{ | ||
"name": "Test 1", | ||
"description": "Ticket test", | ||
} | ||
) | ||
t._compute_access_url() | ||
self.assertEqual(t.access_url, "/my/ticket/%s" % t.id) | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestHelpdeskTicketPostInstall(TestHelpdeskTicketBase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
|
||
cls.Ticket = cls.env["helpdesk.ticket"] | ||
cls.Message = cls.env["mail.message"] | ||
|
||
def test_helpdesk_ticket_assign_notify(self): | ||
t = self.Ticket.create( | ||
{ | ||
"name": "Test 1", | ||
"description": "Ticket test", | ||
} | ||
) | ||
t.user_id = self.user_demo.id | ||
m = self.Message.search( | ||
[ | ||
("model", "=", "helpdesk.ticket"), | ||
("res_id", "=", t.id), | ||
("message_type", "=", "user_notification"), | ||
] | ||
) | ||
self.assertTrue( | ||
"You have been assigned to the Helpdesk Ticket %s" % t.display_name | ||
in m.body | ||
) |