[FIX] sms: fix test helpers calling a removed method

Fix a crash when calling assertSMSStatistics without a number but taking the
number from a partner.

Also fix "sent" sms helper, content should be optional like other helpers.

Task ID 2247037
Community PR #50384
This commit is contained in:
Thibault Delavallée
2020-05-26 10:35:58 +00:00
parent 4a2ac044f8
commit c13c3318b2
2 changed files with 4 additions and 4 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from odoo.addons.mass_mailing.tests.common import MassMailCommon
from odoo.addons.phone_validation.tools import phone_validation
from odoo.addons.sms.tests.common import SMSCase, SMSCommon
@@ -50,7 +49,7 @@ class MassSMSCase(SMSCase):
state = recipient_info.get('state', 'outgoing')
content = recipient_info.get('content', None)
if number is None and partner:
number = phone_validation.phone_get_sanitized_record_number(partner)
number = partner._sms_get_recipients_info()[partner.id]['sanitized']
notif = traces.filtered(lambda s: s.sms_number == number and s.state == state)
self.assertTrue(notif, 'SMS: not found notification for number %s, (state: %s)' % (number, state))
+3 -2
View File
@@ -66,7 +66,7 @@ class SMSCase(MockSMS):
""" Main test class to use when testing SMS integrations. Contains helpers and tools related
to notification sent by SMS. """
def assertSMSSent(self, numbers, content):
def assertSMSSent(self, numbers, content=None):
""" Check sent SMS. Order is not checked. Each number should have received
the same content. Useful to check batch sending.
@@ -76,7 +76,8 @@ class SMSCase(MockSMS):
for number in numbers:
sent_sms = next((sms for sms in self._sms if sms['number'] == number), None)
self.assertTrue(bool(sent_sms), 'Number %s not found in %s' % (number, repr([s['number'] for s in self._sms])))
self.assertEqual(sent_sms['body'], content)
if content is not None:
self.assertEqual(sent_sms['body'], content)
def assertSMSCanceled(self, partner, number, error_code, content=None):
""" Check canceled SMS. Search is done for a pair partner / number where