Skip to content

Commit 11ec160

Browse files
committed
[IMP] project: add some test cases
Added some test cases testing the implemented logic task-4700744
1 parent 05a9e08 commit 11ec160

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { registry } from "@web/core/registry";
2+
import { stepUtils } from "@web_tour/tour_service/tour_utils";
3+
4+
registry.category("web_tour.tours").add("project_templates_tour", {
5+
url: "/odoo",
6+
steps: () => [
7+
stepUtils.showAppsMenuItem(),
8+
{
9+
trigger: '.o_app[data-menu-xmlid="project.menu_main_pm"]',
10+
run: "click",
11+
},
12+
{
13+
content: "Click on New Button of Kanban view",
14+
trigger: "a.o-kanban-button-new",
15+
run: "click",
16+
},
17+
{
18+
trigger: 'ul.dropdown-menu button.dropdown-item:contains("Project Template")',
19+
run: "click",
20+
content: "Create a project from the template",
21+
},
22+
{
23+
trigger: '.modal div[name="name"] .o_input',
24+
run: "edit New Project",
25+
},
26+
{
27+
trigger: 'button[name="create_project_from_template"]',
28+
run: "click",
29+
},
30+
{
31+
content: "Go back to kanban view",
32+
trigger: ".breadcrumb-item a:contains('Projects')",
33+
run: "click",
34+
},
35+
{
36+
content: "Check for created project",
37+
trigger: ".o_kanban_record:contains('New Project')",
38+
},
39+
{
40+
content: "Go to list view",
41+
trigger: "button.o_switch_view.o_list",
42+
run: "click",
43+
},
44+
{
45+
content: "Click on New Button of List view",
46+
trigger: "a.o_list_button_add",
47+
run: "click",
48+
},
49+
{
50+
content: "Lets Create a second project from the template",
51+
trigger: 'ul.dropdown-menu button.dropdown-item:contains("Project Template")',
52+
run: "click",
53+
},
54+
{
55+
content: "Go back to list view",
56+
trigger: ".breadcrumb-item a:contains('Projects')",
57+
run: "click",
58+
},
59+
{
60+
content: "Check for created project",
61+
trigger: ".o_data_row td[name='name']:contains('Project Template')",
62+
},
63+
],
64+
});

addons/project/tests/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from . import test_project_subtasks
1717
from . import test_project_tags_filter
1818
from . import test_project_task_type
19+
from . import test_project_template
20+
from . import test_project_template_ui
1921
from . import test_project_thread_controller
2022
from . import test_project_ui
2123
from . import test_project_update_access_rights
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from odoo.addons.project.tests.test_project_base import TestProjectCommon
2+
3+
4+
class TestProjectTemplates(TestProjectCommon):
5+
@classmethod
6+
def setUpClass(cls):
7+
super().setUpClass()
8+
cls.project_template = cls.env["project.project"].create({
9+
"name": "Project Template",
10+
"is_template": True,
11+
})
12+
cls.task_inside_template = cls.env["project.task"].create({
13+
"name": "Task in Project Template",
14+
"project_id": cls.project_template.id,
15+
})
16+
17+
def test_create_from_template(self):
18+
"""
19+
Creating a project through the action should result in a non template copy
20+
"""
21+
project = self.project_template.action_create_from_template()
22+
self.assertFalse(project.is_template, "The created Project should be a normal project and not a template.")
23+
self.assertFalse(project.partner_id, "The created Project should not have a customer.")
24+
25+
self.assertEqual(len(project.task_ids), 1, "The tasks of the template should be copied too.")
26+
27+
def test_copy_template(self):
28+
"""
29+
A copy of a template should be a template
30+
"""
31+
copied_template = self.project_template.copy()
32+
self.assertTrue(copied_template.is_template, "The copy of the template should also be a template.")
33+
self.assertEqual(len(copied_template.task_ids), 1, "The child of the template should be copied too.")
34+
35+
def test_revert_template(self):
36+
"""
37+
A revert of a template should not be a template
38+
"""
39+
self.project_template.action_undo_convert_to_template()
40+
self.assertFalse(self.project_template.is_template, "The reverted template should become a normal template.")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from odoo.tests import HttpCase, tagged
2+
3+
4+
@tagged("post_install", "-at_install")
5+
class TestProjectTemplatesTour(HttpCase):
6+
@classmethod
7+
def setUpClass(cls):
8+
super().setUpClass()
9+
cls.project_template = cls.env["project.project"].create({
10+
"name": "Project Template",
11+
"is_template": True,
12+
})
13+
cls.task_inside_template = cls.env["project.task"].create({
14+
"name": "Task in Project Template",
15+
"project_id": cls.project_template.id,
16+
})
17+
18+
def test_project_templates_tour(self):
19+
self.start_tour("/odoo", "project_templates_tour", login="admin")

0 commit comments

Comments
 (0)