diff --git a/frappe/core/doctype/communication/test_records.json b/frappe/core/doctype/communication/test_records.json index 914febb225..a69d3e9570 100644 --- a/frappe/core/doctype/communication/test_records.json +++ b/frappe/core/doctype/communication/test_records.json @@ -6,47 +6,5 @@ "sent_or_received": "Received", "parenttype": "User", "parent": "Administrator" - }, - { - "doctype": "Communication", - "name": "_Test Communication 2", - "subject": "Test Communication", - "rating": 50, - "communication_date": "2018-12-30" - }, - { - "doctype": "Communication", - "name": "_Test Communication 3", - "subject": "Test Communication", - "rating": 100, - "communication_date": "2019-1-4" - }, - { - "doctype": "Communication", - "name": "_Test Communication 4", - "subject": "Test Communication", - "rating": 200, - "communication_date": "2019-1-6" - }, - { - "doctype": "Communication", - "name": "_Test Communication 5", - "subject": "Test Communication", - "rating": 400, - "communication_date": "2019-1-7" - }, - { - "doctype": "Communication", - "name": "_Test Communication 6", - "subject": "Test Communication", - "rating": 300, - "communication_date": "2019-1-8" - }, - { - "doctype": "Communication", - "name": "_Test Communication 7", - "subject": "Test Communication", - "rating": 100, - "communication_date": "2019-1-10" } ] diff --git a/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py b/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py index a1b460328f..72ab18385d 100644 --- a/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py +++ b/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py @@ -11,8 +11,6 @@ from frappe.desk.doctype.dashboard_chart.dashboard_chart import get from datetime import datetime from dateutil.relativedelta import relativedelta -test_dependencies = ["Communication"] - class TestDashboardChart(unittest.TestCase): def test_period_ending(self): self.assertEqual(get_period_ending('2019-04-10', 'Daily'), @@ -153,6 +151,7 @@ class TestDashboardChart(unittest.TestCase): frappe.db.rollback() def test_daily_dashboard_chart(self): + insert_test_records() if frappe.db.exists('Dashboard Chart', 'Test Daily Dashboard Chart'): frappe.delete_doc('Dashboard Chart', 'Test Daily Dashboard Chart') @@ -183,6 +182,7 @@ class TestDashboardChart(unittest.TestCase): frappe.db.rollback() def test_weekly_dashboard_chart(self): + insert_test_records() if frappe.db.exists('Dashboard Chart', 'Test Weekly Dashboard Chart'): frappe.delete_doc('Dashboard Chart', 'Test Weekly Dashboard Chart') @@ -213,6 +213,7 @@ class TestDashboardChart(unittest.TestCase): frappe.db.rollback() def test_avg_dashboard_chart(self): + insert_test_records() if frappe.db.exists('Dashboard Chart', 'Test Average Dashboard Chart'): frappe.delete_doc('Dashboard Chart', 'Test Average Dashboard Chart') @@ -241,3 +242,22 @@ class TestDashboardChart(unittest.TestCase): ) frappe.db.rollback() + +def insert_test_records(): + create_new_communication('Communication 1', datetime(2018, 12, 30), 50) + create_new_communication('Communication 2', datetime(2019, 1, 4), 100) + create_new_communication('Communication 3', datetime(2019, 1, 6), 200) + create_new_communication('Communication 4', datetime(2019, 1, 7), 400) + create_new_communication('Communication 5', datetime(2019, 1, 8), 300) + create_new_communication('Communication 6', datetime(2019, 1, 10), 100) + +def create_new_communication(subject, date, rating): + communication = { + 'doctype': 'Communication', + 'subject': subject, + 'rating': rating, + 'communication_date': date + } + comm = frappe.get_doc(communication) + if not frappe.db.exists("Communication", {'subject' : comm.subject}): + comm.insert()