Skip to content

Commit

Permalink
[FIX] helpdesk_mgmt_rating: Fix portal rating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralmau committed Dec 10, 2024
1 parent 497ff7b commit 19ceb3b
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions helpdesk_mgmt_rating/tests/test_helpdesk_portal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import http

from odoo.addons.base.tests.common import HttpCaseWithUserPortal


Expand Down Expand Up @@ -27,22 +29,43 @@ def test_rating_satisfied_ticket(self):
"""Rate satisfied ticket from the portal."""
self.authenticate("portal", "portal")
portal_access_token = self.ticket._rating_get_access_token()
resp = self.url_open(f"/rate/{portal_access_token}/5")
resp = self.url_open(
f"/rate/{portal_access_token}/submit_feedback",
data={
"rate": 5,
"csrf_token": http.Request.csrf_token(self),
"feedback": "good",
},
)
self.assertEqual(resp.status_code, 200)
self.assertEqual(self.ticket.positive_rate_percentage, 100)

def test_rating_not_satisfied_ticket(self):
"""Rate not satisfied ticket from the portal."""
self.authenticate("portal", "portal")
portal_access_token = self.ticket._rating_get_access_token()
resp = self.url_open(f"/rate/{portal_access_token}/3")
resp = self.url_open(
f"/rate/{portal_access_token}/submit_feedback",
data={
"rate": 3,
"csrf_token": http.Request.csrf_token(self),
"feedback": "good",
},
)
self.assertEqual(resp.status_code, 200)
self.assertEqual(self.ticket.positive_rate_percentage, 0)

def test_rating_dissatisfied_ticket(self):
"""Rate highly dissatisfied ticket from the portal."""
self.authenticate("portal", "portal")
portal_access_token = self.ticket._rating_get_access_token()
resp = self.url_open(f"/rate/{portal_access_token}/1")
resp = self.url_open(
f"/rate/{portal_access_token}/submit_feedback",
data={
"rate": 1,
"csrf_token": http.Request.csrf_token(self),
"feedback": "bad job",
},
)
self.assertEqual(resp.status_code, 200)
self.assertEqual(self.ticket.positive_rate_percentage, 0)

0 comments on commit 19ceb3b

Please sign in to comment.