summaryrefslogtreecommitdiff
path: root/addons/test_mail_full/tests/test_sms_server_actions.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/test_mail_full/tests/test_sms_server_actions.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/test_mail_full/tests/test_sms_server_actions.py')
-rw-r--r--addons/test_mail_full/tests/test_sms_server_actions.py67
1 files changed, 67 insertions, 0 deletions
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)