Skip to content

Commit

Permalink
fixup! Add click tests
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Mar 11, 2024
1 parent d8db046 commit 6484d45
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
5 changes: 3 additions & 2 deletions automation_oca/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def setUpClass(cls):
"name": "My template",
"model_id": cls.env.ref("base.model_res_partner").id,
"subject": "Subject",
"partner_to": "{{ object.id }}",
"body_html": 'My template <a href="https://www.twitter.com" /> with link',
}
)
cls.partner_01 = cls.env["res.partner"].create(
{"name": "Demo partner", "comment": "Demo"}
{"name": "Demo partner", "comment": "Demo", "email": "[email protected]"}
)
cls.partner_02 = cls.env["res.partner"].create(
{"name": "Demo partner 2", "comment": "Demo"}
{"name": "Demo partner 2", "comment": "Demo", "email": "[email protected]"}
)
cls.configuration = cls.env["automation.configuration"].create(
{
Expand Down
36 changes: 36 additions & 0 deletions automation_oca/tests/test_automation_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,39 @@ def test_no_open_rejected(self):
self.assertEqual("open", record_activity.mail_status)
self.env["automation.record.activity"]._cron_automation_activities()
self.assertEqual("rejected", record_child_activity.state)

def test_click(self):
"""
Now we will check the execution of scheduled activities"""
with self.mock_mail_gateway():
activity = self.create_mail_activity()
child_activity = self.create_mail_activity(
parent_id=activity.id, trigger_type="mail_click"
)
self.configuration.domain = "[('id', '=', %s)]" % self.partner_01.id
self.configuration.start_automation()
self.env["automation.configuration"].cron_automation()
self.env["automation.record.activity"]._cron_automation_activities()
record_activity = self.env["automation.record.activity"].search(
[("configuration_activity_id", "=", activity.id)]
)
record_child_activity = self.env["automation.record.activity"].search(
[("configuration_activity_id", "=", child_activity.id)]
)
self.assertEqual("sent", record_activity.mail_status)
self.assertTrue(record_child_activity)
self.assertFalse(record_child_activity.scheduled_date)
tracker = self.env["link.tracker"].search(
[("url", "=", "https://www.twitter.com")]
)
self.assertTrue(tracker)
self.url_open(
"/r/%s/au/%s/%s"
% (
tracker.code,
record_activity.id,
record_activity._get_mail_tracking_token(),
)
)
self.assertEqual("open", record_activity.mail_status)
self.assertTrue(record_child_activity.scheduled_date)

0 comments on commit 6484d45

Please sign in to comment.