test: dont create lead manually, add coverage for notes
This commit is contained in:
parent
58e553151e
commit
875ff15109
@ -6,29 +6,20 @@ import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
def create_test_lead():
|
||||
test_lead = frappe.db.get_value("Lead", {"email_id": "test@example.com"})
|
||||
if test_lead:
|
||||
return frappe.get_doc("Lead", test_lead)
|
||||
test_lead = frappe.get_doc(
|
||||
{"doctype": "Lead", "lead_name": "Test Lead", "email_id": "test@example.com"}
|
||||
)
|
||||
test_lead.insert(ignore_permissions=True)
|
||||
return test_lead
|
||||
LEAD_EMAIL = "test_appointment_lead@example.com"
|
||||
|
||||
|
||||
def create_test_appointments():
|
||||
def create_test_appointment():
|
||||
test_appointment = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Appointment",
|
||||
"email": "test@example.com",
|
||||
"status": "Open",
|
||||
"customer_name": "Test Lead",
|
||||
"customer_phone_number": "666",
|
||||
"customer_skype": "test",
|
||||
"customer_email": "test@example.com",
|
||||
"customer_email": LEAD_EMAIL,
|
||||
"scheduled_time": datetime.datetime.now(),
|
||||
"customer_details": "Hello, Friend!",
|
||||
}
|
||||
)
|
||||
test_appointment.insert()
|
||||
@ -36,16 +27,16 @@ def create_test_appointments():
|
||||
|
||||
|
||||
class TestAppointment(unittest.TestCase):
|
||||
test_appointment = test_lead = None
|
||||
def setUpClass():
|
||||
frappe.db.delete("Lead", {"email_id": LEAD_EMAIL})
|
||||
|
||||
def setUp(self):
|
||||
self.test_lead = create_test_lead()
|
||||
self.test_appointment = create_test_appointments()
|
||||
self.test_appointment = create_test_appointment()
|
||||
self.test_appointment.set_verified(self.test_appointment.customer_email)
|
||||
|
||||
def test_calendar_event_created(self):
|
||||
cal_event = frappe.get_doc("Event", self.test_appointment.calendar_event)
|
||||
self.assertEqual(cal_event.starts_on, self.test_appointment.scheduled_time)
|
||||
|
||||
def test_lead_linked(self):
|
||||
lead = frappe.get_doc("Lead", self.test_lead.name)
|
||||
self.assertIsNotNone(lead)
|
||||
self.assertTrue(self.test_appointment.party)
|
||||
|
Loading…
x
Reference in New Issue
Block a user