From 52d1bc9ca66ba520c4e9741cd8271fc390147a1b Mon Sep 17 00:00:00 2001 From: "Bastien (bvdn)" Date: Mon, 11 Sep 2023 18:28:03 +0200 Subject: [PATCH] [IMP] project_todo: write test for the create_todo_activity command We check that both an activity and a task has been created by the create_todo_activity call We check that the task has the same description as the activity.todo.create note We check that the activity and the task have the same: - name - user - deadline Task-3492155 closes odoo/odoo#135134 Signed-off-by: Xavier Bol (xbo) --- addons/project_todo/tests/__init__.py | 1 + .../tests/test_mail_activity_todo_create.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 addons/project_todo/tests/test_mail_activity_todo_create.py diff --git a/addons/project_todo/tests/__init__.py b/addons/project_todo/tests/__init__.py index af79c315e2d..b95d33ba7b8 100644 --- a/addons/project_todo/tests/__init__.py +++ b/addons/project_todo/tests/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from . import test_access_rights +from . import test_mail_activity_todo_create diff --git a/addons/project_todo/tests/test_mail_activity_todo_create.py b/addons/project_todo/tests/test_mail_activity_todo_create.py new file mode 100644 index 00000000000..d22b4f2aacd --- /dev/null +++ b/addons/project_todo/tests/test_mail_activity_todo_create.py @@ -0,0 +1,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('

details

'), + '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('

details

'), '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, 'The Todo and The Activity should have the same date deadline')