|
@ -29,12 +29,12 @@ class TestMailgun(TransactionCase): |
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
def setUp(self): |
|
|
super(TestMailgun, self).setUp() |
|
|
super(TestMailgun, self).setUp() |
|
|
self.recipient = u'to@example.com' |
|
|
|
|
|
|
|
|
self.recipient = 'to@example.com' |
|
|
self.mail, self.tracking_email = self.mail_send() |
|
|
self.mail, self.tracking_email = self.mail_send() |
|
|
self.api_key = u'key-12345678901234567890123456789012' |
|
|
|
|
|
self.domain = u'example.com' |
|
|
|
|
|
self.token = u'f1349299097a51b9a7d886fcb5c2735b426ba200ada6e9e149' |
|
|
|
|
|
self.timestamp = u'1471021089' |
|
|
|
|
|
|
|
|
self.api_key = 'key-12345678901234567890123456789012' |
|
|
|
|
|
self.domain = 'example.com' |
|
|
|
|
|
self.token = 'f1349299097a51b9a7d886fcb5c2735b426ba200ada6e9e149' |
|
|
|
|
|
self.timestamp = '1471021089' |
|
|
self.signature = ('4fb6d4dbbe10ce5d620265dcd7a3c0b8' |
|
|
self.signature = ('4fb6d4dbbe10ce5d620265dcd7a3c0b8' |
|
|
'ca0dede1433103891bc1ae4086e9d5b2') |
|
|
'ca0dede1433103891bc1ae4086e9d5b2') |
|
|
self.env['ir.config_parameter'].set_param( |
|
|
self.env['ir.config_parameter'].set_param( |
|
@ -46,17 +46,17 @@ class TestMailgun(TransactionCase): |
|
|
self.env['ir.config_parameter'].set_param( |
|
|
self.env['ir.config_parameter'].set_param( |
|
|
'mailgun.auto_check_partner_email', '') |
|
|
'mailgun.auto_check_partner_email', '') |
|
|
self.event = { |
|
|
self.event = { |
|
|
'Message-Id': u'<xxx.xxx.xxx-openerp-xxx-res.partner@test_db>', |
|
|
|
|
|
'X-Mailgun-Sid': u'WyIwNjgxZSIsICJ0b0BleGFtcGxlLmNvbSIsICI3MG' |
|
|
|
|
|
|
|
|
'Message-Id': '<xxx.xxx.xxx-openerp-xxx-res.partner@test_db>', |
|
|
|
|
|
'X-Mailgun-Sid': 'WyIwNjgxZSIsICJ0b0BleGFtcGxlLmNvbSIsICI3MG' |
|
|
'I0MWYiXQ==', |
|
|
'I0MWYiXQ==', |
|
|
'token': self.token, |
|
|
'token': self.token, |
|
|
'timestamp': self.timestamp, |
|
|
'timestamp': self.timestamp, |
|
|
'signature': self.signature, |
|
|
'signature': self.signature, |
|
|
'domain': u'example.com', |
|
|
|
|
|
'message-headers': u'[]', |
|
|
|
|
|
|
|
|
'domain': 'example.com', |
|
|
|
|
|
'message-headers': '[]', |
|
|
'recipient': self.recipient, |
|
|
'recipient': self.recipient, |
|
|
'odoo_db': self.env.cr.dbname, |
|
|
'odoo_db': self.env.cr.dbname, |
|
|
'tracking_email_id': u'%s' % self.tracking_email.id |
|
|
|
|
|
|
|
|
'tracking_email_id': '%s' % self.tracking_email.id |
|
|
} |
|
|
} |
|
|
self.metadata = { |
|
|
self.metadata = { |
|
|
'ip': '127.0.0.1', |
|
|
'ip': '127.0.0.1', |
|
@ -110,8 +110,8 @@ class TestMailgun(TransactionCase): |
|
|
'.mail_tracking_email') |
|
|
'.mail_tracking_email') |
|
|
def test_bad_signature(self): |
|
|
def test_bad_signature(self): |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'delivered', |
|
|
|
|
|
'signature': u'bad_signature', |
|
|
|
|
|
|
|
|
'event': 'delivered', |
|
|
|
|
|
'signature': 'bad_signature', |
|
|
}) |
|
|
}) |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
None, self.event, self.metadata) |
|
|
None, self.event, self.metadata) |
|
@ -121,7 +121,7 @@ class TestMailgun(TransactionCase): |
|
|
'.mail_tracking_email') |
|
|
'.mail_tracking_email') |
|
|
def test_bad_event_type(self): |
|
|
def test_bad_event_type(self): |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'bad_event', |
|
|
|
|
|
|
|
|
'event': 'bad_event', |
|
|
}) |
|
|
}) |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
None, self.event, self.metadata) |
|
|
None, self.event, self.metadata) |
|
@ -131,19 +131,19 @@ class TestMailgun(TransactionCase): |
|
|
'.mail_tracking_email') |
|
|
'.mail_tracking_email') |
|
|
def test_bad_db(self): |
|
|
def test_bad_db(self): |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'delivered', |
|
|
|
|
|
'odoo_db': u'bad_db', |
|
|
|
|
|
|
|
|
'event': 'delivered', |
|
|
|
|
|
'odoo_db': 'bad_db', |
|
|
}) |
|
|
}) |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
None, self.event, self.metadata) |
|
|
None, self.event, self.metadata) |
|
|
self.assertEqual('ERROR: Invalid DB', response) |
|
|
self.assertEqual('ERROR: Invalid DB', response) |
|
|
|
|
|
|
|
|
def test_bad_ts(self): |
|
|
def test_bad_ts(self): |
|
|
timestamp = u'7a' # Now time will be used instead |
|
|
|
|
|
|
|
|
timestamp = '7a' # Now time will be used instead |
|
|
signature = ('06cc05680f6e8110e59b41152b2d1c0f' |
|
|
signature = ('06cc05680f6e8110e59b41152b2d1c0f' |
|
|
'1045d755ef2880ff922344325c89a6d4') |
|
|
'1045d755ef2880ff922344325c89a6d4') |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'delivered', |
|
|
|
|
|
|
|
|
'event': 'delivered', |
|
|
'timestamp': timestamp, |
|
|
'timestamp': timestamp, |
|
|
'signature': signature, |
|
|
'signature': signature, |
|
|
}) |
|
|
}) |
|
@ -155,8 +155,8 @@ class TestMailgun(TransactionCase): |
|
|
'.mail_tracking_email') |
|
|
'.mail_tracking_email') |
|
|
def test_tracking_not_found(self): |
|
|
def test_tracking_not_found(self): |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'delivered', |
|
|
|
|
|
'tracking_email_id': u'bad_id', |
|
|
|
|
|
|
|
|
'event': 'delivered', |
|
|
|
|
|
'tracking_email_id': 'bad_id', |
|
|
}) |
|
|
}) |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
None, self.event, self.metadata) |
|
|
None, self.event, self.metadata) |
|
@ -165,7 +165,7 @@ class TestMailgun(TransactionCase): |
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-deliveries |
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-deliveries |
|
|
def test_event_delivered(self): |
|
|
def test_event_delivered(self): |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'delivered', |
|
|
|
|
|
|
|
|
'event': 'delivered', |
|
|
}) |
|
|
}) |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
None, self.event, self.metadata) |
|
|
None, self.event, self.metadata) |
|
@ -176,20 +176,20 @@ class TestMailgun(TransactionCase): |
|
|
|
|
|
|
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-opens |
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-opens |
|
|
def test_event_opened(self): |
|
|
def test_event_opened(self): |
|
|
ip = u'127.0.0.1' |
|
|
|
|
|
user_agent = u'Odoo Test/8.0 Gecko Firefox/11.0' |
|
|
|
|
|
os_family = u'Linux' |
|
|
|
|
|
ua_family = u'Firefox' |
|
|
|
|
|
ua_type = u'browser' |
|
|
|
|
|
|
|
|
ip = '127.0.0.1' |
|
|
|
|
|
user_agent = 'Odoo Test/8.0 Gecko Firefox/11.0' |
|
|
|
|
|
os_family = 'Linux' |
|
|
|
|
|
ua_family = 'Firefox' |
|
|
|
|
|
ua_type = 'browser' |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'opened', |
|
|
|
|
|
'city': u'Mountain View', |
|
|
|
|
|
'country': u'US', |
|
|
|
|
|
'region': u'CA', |
|
|
|
|
|
|
|
|
'event': 'opened', |
|
|
|
|
|
'city': 'Mountain View', |
|
|
|
|
|
'country': 'US', |
|
|
|
|
|
'region': 'CA', |
|
|
'client-name': ua_family, |
|
|
'client-name': ua_family, |
|
|
'client-os': os_family, |
|
|
'client-os': os_family, |
|
|
'client-type': ua_type, |
|
|
'client-type': ua_type, |
|
|
'device-type': u'desktop', |
|
|
|
|
|
|
|
|
'device-type': 'desktop', |
|
|
'ip': ip, |
|
|
'ip': ip, |
|
|
'user-agent': user_agent, |
|
|
'user-agent': user_agent, |
|
|
}) |
|
|
}) |
|
@ -209,21 +209,21 @@ class TestMailgun(TransactionCase): |
|
|
|
|
|
|
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-clicks |
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-clicks |
|
|
def test_event_clicked(self): |
|
|
def test_event_clicked(self): |
|
|
ip = u'127.0.0.1' |
|
|
|
|
|
user_agent = u'Odoo Test/8.0 Gecko Firefox/11.0' |
|
|
|
|
|
os_family = u'Linux' |
|
|
|
|
|
ua_family = u'Firefox' |
|
|
|
|
|
ua_type = u'browser' |
|
|
|
|
|
url = u'https://odoo-community.org' |
|
|
|
|
|
|
|
|
ip = '127.0.0.1' |
|
|
|
|
|
user_agent = 'Odoo Test/8.0 Gecko Firefox/11.0' |
|
|
|
|
|
os_family = 'Linux' |
|
|
|
|
|
ua_family = 'Firefox' |
|
|
|
|
|
ua_type = 'browser' |
|
|
|
|
|
url = 'https://odoo-community.org' |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'clicked', |
|
|
|
|
|
'city': u'Mountain View', |
|
|
|
|
|
'country': u'US', |
|
|
|
|
|
'region': u'CA', |
|
|
|
|
|
|
|
|
'event': 'clicked', |
|
|
|
|
|
'city': 'Mountain View', |
|
|
|
|
|
'country': 'US', |
|
|
|
|
|
'region': 'CA', |
|
|
'client-name': ua_family, |
|
|
'client-name': ua_family, |
|
|
'client-os': os_family, |
|
|
'client-os': os_family, |
|
|
'client-type': ua_type, |
|
|
'client-type': ua_type, |
|
|
'device-type': u'tablet', |
|
|
|
|
|
|
|
|
'device-type': 'tablet', |
|
|
'ip': ip, |
|
|
'ip': ip, |
|
|
'user-agent': user_agent, |
|
|
'user-agent': user_agent, |
|
|
'url': url, |
|
|
'url': url, |
|
@ -244,20 +244,20 @@ class TestMailgun(TransactionCase): |
|
|
|
|
|
|
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-unsubscribes |
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-unsubscribes |
|
|
def test_event_unsubscribed(self): |
|
|
def test_event_unsubscribed(self): |
|
|
ip = u'127.0.0.1' |
|
|
|
|
|
user_agent = u'Odoo Test/8.0 Gecko Firefox/11.0' |
|
|
|
|
|
os_family = u'Linux' |
|
|
|
|
|
ua_family = u'Firefox' |
|
|
|
|
|
ua_type = u'browser' |
|
|
|
|
|
|
|
|
ip = '127.0.0.1' |
|
|
|
|
|
user_agent = 'Odoo Test/8.0 Gecko Firefox/11.0' |
|
|
|
|
|
os_family = 'Linux' |
|
|
|
|
|
ua_family = 'Firefox' |
|
|
|
|
|
ua_type = 'browser' |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'unsubscribed', |
|
|
|
|
|
'city': u'Mountain View', |
|
|
|
|
|
'country': u'US', |
|
|
|
|
|
'region': u'CA', |
|
|
|
|
|
|
|
|
'event': 'unsubscribed', |
|
|
|
|
|
'city': 'Mountain View', |
|
|
|
|
|
'country': 'US', |
|
|
|
|
|
'region': 'CA', |
|
|
'client-name': ua_family, |
|
|
'client-name': ua_family, |
|
|
'client-os': os_family, |
|
|
'client-os': os_family, |
|
|
'client-type': ua_type, |
|
|
'client-type': ua_type, |
|
|
'device-type': u'mobile', |
|
|
|
|
|
|
|
|
'device-type': 'mobile', |
|
|
'ip': ip, |
|
|
'ip': ip, |
|
|
'user-agent': user_agent, |
|
|
'user-agent': user_agent, |
|
|
}) |
|
|
}) |
|
@ -278,7 +278,7 @@ class TestMailgun(TransactionCase): |
|
|
# user_manual.html#tracking-spam-complaints |
|
|
# user_manual.html#tracking-spam-complaints |
|
|
def test_event_complained(self): |
|
|
def test_event_complained(self): |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'complained', |
|
|
|
|
|
|
|
|
'event': 'complained', |
|
|
}) |
|
|
}) |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
response = self.env['mail.tracking.email'].event_process( |
|
|
None, self.event, self.metadata) |
|
|
None, self.event, self.metadata) |
|
@ -290,12 +290,12 @@ class TestMailgun(TransactionCase): |
|
|
|
|
|
|
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-bounces |
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-bounces |
|
|
def test_event_bounced(self): |
|
|
def test_event_bounced(self): |
|
|
code = u'550' |
|
|
|
|
|
error = (u"5.1.1 The email account does not exist.\n" |
|
|
|
|
|
|
|
|
code = '550' |
|
|
|
|
|
error = ("5.1.1 The email account does not exist.\n" |
|
|
"5.1.1 double-checking the recipient's email address") |
|
|
"5.1.1 double-checking the recipient's email address") |
|
|
notification = u"Please, check recipient's email address" |
|
|
|
|
|
|
|
|
notification = "Please, check recipient's email address" |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'bounced', |
|
|
|
|
|
|
|
|
'event': 'bounced', |
|
|
'code': code, |
|
|
'code': code, |
|
|
'error': error, |
|
|
'error': error, |
|
|
'notification': notification, |
|
|
'notification': notification, |
|
@ -312,11 +312,11 @@ class TestMailgun(TransactionCase): |
|
|
|
|
|
|
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-failures |
|
|
# https://documentation.mailgun.com/user_manual.html#tracking-failures |
|
|
def test_event_dropped(self): |
|
|
def test_event_dropped(self): |
|
|
reason = u'hardfail' |
|
|
|
|
|
code = u'605' |
|
|
|
|
|
description = u'Not delivering to previously bounced address' |
|
|
|
|
|
|
|
|
reason = 'hardfail' |
|
|
|
|
|
code = '605' |
|
|
|
|
|
description = 'Not delivering to previously bounced address' |
|
|
self.event.update({ |
|
|
self.event.update({ |
|
|
'event': u'dropped', |
|
|
|
|
|
|
|
|
'event': 'dropped', |
|
|
'reason': reason, |
|
|
'reason': reason, |
|
|
'code': code, |
|
|
'code': code, |
|
|
'description': description, |
|
|
'description': description, |
|
|