Skip to content

Commit

Permalink
test: add test case for Task having common subject
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Sep 11, 2023
1 parent 345bc26 commit efeef9f
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions erpnext/projects/doctype/project/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,48 @@ def test_project_linking_with_sales_order(self):
so.reload()
self.assertFalse(so.project)

def test_project_with_template_tasks_having_common_name(self):
# Step - 1: Create Template Parent Tasks
template_parent_task1 = create_task(subject="Parent Task - 1", is_template=1, is_group=1)
template_parent_task2 = create_task(subject="Parent Task - 2", is_template=1, is_group=1)
template_parent_task3 = create_task(subject="Parent Task - 1", is_template=1, is_group=1)

# Step - 2: Create Template Child Tasks
template_task1 = create_task(
subject="Task - 1", is_template=1, parent_task=template_parent_task1.name
)
template_task2 = create_task(
subject="Task - 2", is_template=1, parent_task=template_parent_task2.name
)
template_task2 = create_task(
subject="Task - 1", is_template=1, parent_task=template_parent_task3.name
)

# Create - 3: Create Project Template
template_tasks = [
template_parent_task1,
template_task1,
template_parent_task2,
template_task2,
]
project_template = make_project_template(
"Project template with common Task Subject", template_tasks
)

# Step - 4: Create Project against the Project Template
project = get_project("Project with common Task Subject", project_template)
project_tasks = frappe.get_all(
"Task", {"project": project.name}, ["subject", "parent_task", "is_group"]
)

# Test - 1: No. of Project Tasks should be equal to No. of Template Tasks
self.assertEquals(len(project_tasks), len(template_tasks))

# Test - 2: All child Project Tasks should have Parent Task linked
for pt in project_tasks:
if not pt.is_group:
self.assertIsNotNone(pt.parent_task)


def get_project(name, template):

Expand Down

0 comments on commit efeef9f

Please sign in to comment.