Skip to content

Commit dc8e654

Browse files
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM+MPHfW8vX4CgPA9taZb1mBMAs/IJYfo41AHEi6N46i m.francke@secure42.de
[IMP] increase test coverage [IMP] increase test coverage [IMP] increase test coverage fghf fgghf dfdfg dffg
1 parent f952b15 commit dc8e654

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

mail_quoted_reply/tests/test_reply.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,49 @@ def test_unquoted_reply(self):
7171
wizard = (
7272
self.env[action["res_model"]].with_context(**action["context"]).create({})
7373
)
74+
wizard = wizard.with_context(
75+
default_subject="Some subject for testing purposes",
76+
)
77+
self.assertTrue(wizard.partner_ids)
78+
self.assertEqual(message.email_from, wizard.partner_ids.email_formatted)
79+
# the onchange in the composer isn't triggered in tests, so we check for the
80+
# correct quote in the context
81+
email_quote = re.search("<p>.*?</p>", wizard.env.context["quote_body"]).group()
82+
self.assertEqual("<p>demo message</p>", email_quote)
83+
wizard.action_send_mail()
84+
new_message = partner.message_ids.filtered(
85+
lambda r: r.message_type != "notification" and r != message
86+
)
87+
self.assertTrue(new_message)
88+
self.assertEqual(1, len(new_message))
89+
90+
def test_reply_with_existing_body(self):
91+
partner = self.env["res.partner"].create({"name": "demo partner"})
92+
self.assertFalse(
93+
partner.message_ids.filtered(lambda r: r.message_type != "notification")
94+
)
95+
# pylint: disable=C8107
96+
message = partner.message_post(
97+
body="demo message",
98+
message_type="email",
99+
partner_ids=self.env.ref("base.partner_admin").ids,
100+
)
101+
partner.invalidate_recordset()
102+
self.assertIn(
103+
message,
104+
partner.message_ids.filtered(lambda r: r.message_type != "notification"),
105+
)
106+
self.assertFalse(
107+
partner.message_ids.filtered(
108+
lambda r: r.message_type != "notification" and r != message
109+
)
110+
)
111+
action = message.reply_message()
112+
action["context"]["is_quoted_reply"] = False
113+
wizard = (
114+
self.env[action["res_model"]].with_context(**action["context"]).create({})
115+
)
116+
wizard.body = "Some body for testing purposes"
74117
self.assertTrue(wizard.partner_ids)
75118
self.assertEqual(message.email_from, wizard.partner_ids.email_formatted)
76119
# the onchange in the composer isn't triggered in tests, so we check for the

mail_quoted_reply/wizard/mail_compose_message.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from markupsafe import Markup
22

3-
from odoo import api, models, tools
3+
from odoo import api, models
44

55

66
class MailComposeMessage(models.TransientModel):
@@ -31,7 +31,8 @@ def _compute_body(self):
3131
def _compute_subject(self):
3232
res = super()._compute_subject()
3333
for composer in self:
34-
subj = composer.env.context.get("default_subject", False)
34+
context = composer.env.context
35+
subj = context.get("default_subject", False)
3536
if subj:
36-
composer.subject = tools.ustr(subj)
37+
composer.subject = str(subj)
3738
return res

0 commit comments

Comments
 (0)