|
| 1 | +# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 2 | + |
| 3 | +from odoo import fields |
| 4 | +from odoo.tests.common import TransactionCase |
| 5 | +from odoo.tests import tagged, Form |
| 6 | + |
| 7 | + |
| 8 | +@tagged('post_install', '-at_install') |
| 9 | +class TattooShopAutomationsTestCase(TransactionCase): |
| 10 | + @classmethod |
| 11 | + def setUpClass(cls): |
| 12 | + super().setUpClass() |
| 13 | + cls.partner = cls.env['res.partner'].create({ |
| 14 | + 'name': 'Tattoo Customer', |
| 15 | + |
| 16 | + }) |
| 17 | + # Create a lead to use in tests |
| 18 | + cls.lead = cls.env['crm.lead'].create({ |
| 19 | + 'name': 'Tattoo Inquiry', |
| 20 | + 'partner_id': cls.partner.id, |
| 21 | + 'stage_id': cls.env.ref('crm.stage_lead1').id, |
| 22 | + }) |
| 23 | + |
| 24 | + def test_booking_link_sent_automation(self): |
| 25 | + nb_mail = self.env['mail.mail'].search_count([]) |
| 26 | + # Trigger automation |
| 27 | + with Form(self.lead) as lead_form: |
| 28 | + lead_form.stage_id = self.env.ref('crm.stage_lead3') |
| 29 | + nb_mail_after = self.env['mail.mail'].search_count([]) |
| 30 | + self.assertEqual(nb_mail_after, nb_mail + 1, "An email should be sent when the stage is changed to 'Booking Link Sent'") |
| 31 | + |
| 32 | + def test_aftercare_automation(self): |
| 33 | + nb_mail = self.env['mail.mail'].search_count([]) |
| 34 | + # Trigger automation |
| 35 | + with Form(self.lead) as lead_form: |
| 36 | + lead_form.stage_id = self.env.ref('tattoo_shop.crm_stage_7') |
| 37 | + nb_mail_after = self.env['mail.mail'].search_count([]) |
| 38 | + self.assertEqual(nb_mail_after, nb_mail + 1, "An email should be sent when the stage is changed to 'Aftercare'") |
0 commit comments