From 5945144c08e00966a4cdbeb662e29be9d0952c0b Mon Sep 17 00:00:00 2001 From: Pranav Nachanekar Date: Mon, 9 Sep 2019 16:35:48 +0530 Subject: [PATCH] Added tests --- .../doctype/appointment/test_appointment.py | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/erpnext/crm/doctype/appointment/test_appointment.py b/erpnext/crm/doctype/appointment/test_appointment.py index 702ac7176f..e446712d01 100644 --- a/erpnext/crm/doctype/appointment/test_appointment.py +++ b/erpnext/crm/doctype/appointment/test_appointment.py @@ -3,8 +3,45 @@ # See license.txt from __future__ import unicode_literals -# import frappe +import frappe import unittest +import datetime + + +def create_appointments(number): + for i in range(1, number): + frappe.get_doc({ + 'doctype': 'Appointment', + 'scheduled_time': datetime.datetime.min, + 'customer_name': 'Test Customer'+str(i), + 'customer_phone_number': '8088', + 'customer_skype': 'test'+str(i), + }) + class TestAppointment(unittest.TestCase): - pass + def setUp(self): + settings = frappe.get_doc('Appointment Booking Settings') + create_appointments(settings.number_of_agents) + frappe.get_doc({ + 'doctype': 'Appointment', + 'scheduled_time': datetime.datetime.min, + 'customer_name': 'Extra Customer', + 'customer_phone_number': '8088', + 'customer_skype': 'extra_customer', + }) + + def tearDown(self): + delete_appointments() + + def delete_appointments(self): + doc_list = frappe.get_list('Appointment',filters={'scheduled_time':datetime.datetime.min,'customer_phone_number':'8088'}) + for doc in doc_list: + doc.delete() + + def test_number_of_appointments(self): + settings = frappe.get_doc('Appointment Booking Settings') + self.assertLessEqual(frappe.db.count('Apoointment', + filters={'scheduled_time': datetime.datetime.min, 'customer_name':}), + settings.number_of_agents, + "Number of appointments exceed number of agents")