summaryrefslogtreecommitdiff
path: root/addons/link_tracker
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2021-04-16 11:52:45 +0000
committerThibault Delavallée <tde@odoo.com>2021-04-19 14:11:13 +0000
commite77b9e575e398f42df524bdaf5d692ea882a4521 (patch)
treedd846e1a25aea75549126c77fd7504caa79e4c25 /addons/link_tracker
parent509d761921167a041bfe5dd403181d399c20dacc (diff)
[IMP] event_sms, link_tracker, sms, test_mail_full: improve SMS-based mailing tests
PURPOSE Purpose is to have more tests when sending sms mailings, notably about canceled or failed mails or sms as well as jinja and links rendering. SPECIFICATIONS In this commit we improve SMS Marketing mailing tests. We notably * add tests for void and invalid email and numbers. It allows to check they correctly update their trace status; * add tests for unsubscribe and view links embedded in sms marketing; * add tests to simulate a click on links sent through sms marketing and ensure click statistics are effectively updated; * ensure content of sent sms are checked; Default content of mailings used in test is updated to ensure jinja is correctly rendered, including links and some corner cases. This will also helps ensuring behavior is kept when converting to QWeb. In event we now correctly use sms gateway mock to ensure SMS finding. In link_tracker a helper is added to check url tracking in plaintext content. LINKS Task ID-2508643 Followup of odoo/odoo#68874 (improve mail tests) Prepares Task ID-27033 (support QWeb in templates) Prepares Task ID-2377974 (clean trace and status management in mass mailing) COM PR odoo/odoo#69461 ENT PR odoo/enterprise#17780
Diffstat (limited to 'addons/link_tracker')
-rw-r--r--addons/link_tracker/tests/common.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/link_tracker/tests/common.py b/addons/link_tracker/tests/common.py
index 6daa1489465..eda2229178c 100644
--- a/addons/link_tracker/tests/common.py
+++ b/addons/link_tracker/tests/common.py
@@ -52,6 +52,25 @@ class MockLinkTracker(common.BaseCase):
self.assertTrue('/r/' not in anchor_href, '%s should not be shortened: %s' % (anchor_id, anchor_href))
self.assertEqual(anchor_href, url)
+ def assertLinkShortenedText(self, body, link_info, link_params=None):
+ """ Find shortened links in an text content. Usage :
+
+ self.assertLinkShortenedText(
+ message.body,
+ ('http://www.odoo.com', True),
+ {'utm_campaign': self.utm_c.name, 'utm_medium': self.utm_m.name}
+ )
+ """
+ (url, is_shortened) = link_info
+ link_tracker = self.env['link.tracker'].search([('url', '=', url)])
+ if is_shortened:
+ self.assertEqual(len(link_tracker), 1)
+ self.assertIn(link_tracker.short_url, body, '%s should be shortened' % (url))
+ self.assertLinkParams(url, link_tracker, link_params=link_params)
+ else:
+ self.assertEqual(len(link_tracker), 0)
+ self.assertIn(url, body)
+
def assertLinkParams(self, url, link_tracker, link_params=None):
""" Usage