From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- .../tests/test_sms_server_actions.py | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 addons/test_mail_full/tests/test_sms_server_actions.py (limited to 'addons/test_mail_full/tests/test_sms_server_actions.py') diff --git a/addons/test_mail_full/tests/test_sms_server_actions.py b/addons/test_mail_full/tests/test_sms_server_actions.py new file mode 100644 index 00000000..1c06123e --- /dev/null +++ b/addons/test_mail_full/tests/test_sms_server_actions.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.addons.test_mail_full.tests.common import TestMailFullCommon, TestRecipients + + +class TestServerAction(TestMailFullCommon, TestRecipients): + + @classmethod + def setUpClass(cls): + super(TestServerAction, cls).setUpClass() + cls.test_record = cls.env['mail.test.sms'].with_context(**cls._test_context).create({ + 'name': 'Test', + 'customer_id': cls.partner_1.id, + }) + cls.test_record_2 = cls.env['mail.test.sms'].with_context(**cls._test_context).create({ + 'name': 'Test Record 2', + 'customer_id': False, + 'phone_nbr': cls.test_numbers[0], + }) + + cls.sms_template = cls._create_sms_template('mail.test.sms') + cls.action = cls.env['ir.actions.server'].create({ + 'name': 'Test SMS Action', + 'model_id': cls.env['ir.model']._get('mail.test.sms').id, + 'state': 'sms', + 'sms_template_id': cls.sms_template.id, + 'groups_id': cls.env.ref('base.group_user'), + }) + + def test_action_sms(self): + context = { + 'active_model': 'mail.test.sms', + 'active_ids': (self.test_record | self.test_record_2).ids, + } + + with self.with_user('employee'), self.mockSMSGateway(): + self.action.with_user(self.env.user).with_context(**context).run() + + self.assertSMSOutgoing(self.test_record.customer_id, None, content='Dear %s this is an SMS.' % self.test_record.display_name) + self.assertSMSOutgoing(self.env['res.partner'], self.test_numbers_san[0], content='Dear %s this is an SMS.' % self.test_record_2.display_name) + + def test_action_sms_single(self): + context = { + 'active_model': 'mail.test.sms', + 'active_id': self.test_record.id, + } + + with self.with_user('employee'), self.mockSMSGateway(): + self.action.with_user(self.env.user).with_context(**context).run() + self.assertSMSOutgoing(self.test_record.customer_id, None, content='Dear %s this is an SMS.' % self.test_record.display_name) + + def test_action_sms_w_log(self): + self.action.sms_mass_keep_log = True + context = { + 'active_model': 'mail.test.sms', + 'active_ids': (self.test_record | self.test_record_2).ids, + } + + with self.with_user('employee'), self.mockSMSGateway(): + self.action.with_user(self.env.user).with_context(**context).run() + + self.assertSMSOutgoing(self.test_record.customer_id, None, content='Dear %s this is an SMS.' % self.test_record.display_name) + self.assertSMSLogged(self.test_record, 'Dear %s this is an SMS.' % self.test_record.display_name) + + self.assertSMSOutgoing(self.env['res.partner'], self.test_numbers_san[0], content='Dear %s this is an SMS.' % self.test_record_2.display_name) + self.assertSMSLogged(self.test_record_2, 'Dear %s this is an SMS.' % self.test_record_2.display_name) -- cgit v1.2.3