File: test_event_mail.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (36 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from datetime import datetime, timedelta

from odoo.addons.mail.tests.common import  MailCommon
from odoo.tests import tagged

@tagged('post_install', '-at_install')
class TestMail(MailCommon):

    def test_website_publish_notification(self):
        """ Test that the published/unpublished notifications are sent when publishing/unpublishing an event"""
        published_subtype = self.env.ref('website_event.mt_event_published')
        unpublished_subtype = self.env.ref('website_event.mt_event_unpublished')
        event = self.env['event.event'].create({
            'name': 'Event',
            'date_begin': datetime.today() - timedelta(days=1),
            'date_end': datetime.today() + timedelta(days=1),
        })
        self.flush_tracking()

        follower = self.user_employee.partner_id
        event.message_subscribe(partner_ids=follower.ids, subtype_ids=[published_subtype.id, unpublished_subtype.id])

        event.website_published = True
        self.flush_tracking()

        event.website_published = False
        self.flush_tracking()

        unpublished_message, published_message, creation_message = event.message_ids

        self.assertEqual(unpublished_message.subtype_id, unpublished_subtype)
        self.assertEqual(published_message.subtype_id, published_subtype)
        self.assertEqual(creation_message.subtype_id, self.env.ref('mail.mt_note'))