From 4c8c50e464680ceb4e5742120b05d232fe60deac Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Wed, 2 Jan 2019 17:52:28 +0530 Subject: [PATCH] test case fixed --- erpnext/projects/doctype/task/task.py | 9 +++++---- erpnext/projects/doctype/task/test_task.py | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index 855e2006f9..63db6cdea5 100755 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -44,10 +44,11 @@ class Task(NestedSet): if self.act_start_date and self.act_end_date and getdate(self.act_start_date) > getdate(self.act_end_date): frappe.throw(_("'Actual Start Date' can not be greater than 'Actual End Date'")) - doc = frappe.get_doc("Project", self.project) - if self.exp_end_date and doc.expected_end_date and getdate(self.exp_end_date) > getdate(doc.expected_end_date) : - frappe.msgprint(_("Expected end date cannot be after Project: '{0}' Expected end date").format(doc.name)) - raise EndDateConnotGreaterThanProjecteEndDateError + if(self.project): + doc = frappe.get_doc("Project", self.project) + if self.exp_end_date and doc.expected_end_date and getdate(self.exp_end_date) > getdate(doc.expected_end_date) : + frappe.msgprint(_("Expected end date cannot be after Project: '{0}' Expected end date").format(doc.name)) + raise EndDateConnotGreaterThanProjecteEndDateError def validate_status(self): if self.status!=self.get_db_value("status") and self.status == "Closed": diff --git a/erpnext/projects/doctype/task/test_task.py b/erpnext/projects/doctype/task/test_task.py index 058f6b8d0d..1585e798be 100644 --- a/erpnext/projects/doctype/task/test_task.py +++ b/erpnext/projects/doctype/task/test_task.py @@ -9,7 +9,7 @@ from erpnext.projects.doctype.task.task import CircularReferenceError, EndDateCo class TestTask(unittest.TestCase): def test_circular_reference(self): - task1 = create_task("_Test Task 1", nowdate(), add_days(nowdate(), 10)) + task1 = create_task("_Test Task 1", add_days(nowdate(), -15), add_days(nowdate(), -10)) task2 = create_task("_Test Task 2", add_days(nowdate(), 11), add_days(nowdate(), 15), task1.name) task3 = create_task("_Test Task 3", add_days(nowdate(), 11), add_days(nowdate(), 15), task2.name) @@ -98,15 +98,15 @@ class TestTask(unittest.TestCase): self.assertEqual(frappe.db.get_value("Task", task.name, "status"), "Overdue") def test_end_date_validation(self): - task_end = create_task("Testing_Enddate_validation", add_days(nowdate(), -10), add_days(nowdate(), 5), save=False) + task_end = create_task("Testing_Enddate_validation", add_days(nowdate(), 35), add_days(nowdate(), 45), save=False) pro = frappe.get_doc("Project", task_end.project) - pro.expected_end_date = add_days(nowdate(), 20) + pro.expected_end_date = add_days(nowdate(), 40) pro.save() self.assertRaises(EndDateConnotGreaterThanProjecteEndDateError, task_end.save) -def create_task(subject, start=None, end=None, save=True, depends_on=None, project=None): +def create_task(subject, start=None, end=None, depends_on=None, project=None, save=True): if not frappe.db.exists("Task", subject): task = frappe.new_doc('Task') task.status = "Open"