File: test_mail_activity_todo_create.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 (29 lines) | stat: -rw-r--r-- 1,551 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
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import datetime
from markupsafe import Markup
from odoo.tests.common import TransactionCase


class TestMailActivityTodo(TransactionCase):

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.mail_activity = cls.env['mail.activity.todo.create'].create({
            'summary': 'test_summary',
            'date_deadline': datetime.date.today(),
            'note': Markup('<p>details</p>'),
            'user_id': cls.env.ref('base.user_admin').id,
        })
        cls.mail_activity.create_todo_activity()

    def test_create_todo_activity(self):
        todo_1 = self.env['project.task'].search([('name', 'ilike', 'test_summary')], limit=1)
        activity_1 = self.env['mail.activity'].search([('summary', 'ilike', 'test_summary')], limit=1)
        self.assertTrue(todo_1.exists(), 'A Todo should have been created')
        self.assertEqual(todo_1.description, Markup('<p>details</p>'), 'The Todo description should be the same as the mail.activity.todo.create note')
        self.assertTrue(activity_1.exists(), 'An Activity should have been created')
        self.assertEqual(activity_1.summary, todo_1.name, 'The Todo and The Activity should have the same name/summary')
        self.assertEqual(activity_1.user_id, todo_1.user_ids, 'The Todo and The Activity should have the same user')
        self.assertEqual(activity_1.date_deadline, todo_1.date_deadline.date(), 'The Todo and The Activity should have the same date deadline')