From cc74ab39a04fa0d95dffe31080ea96abf690b0ee Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Sun, 15 Sep 2019 20:38:17 +0530 Subject: [PATCH] test: fix test cases --- .../contacts/doctype/contact/test_contact.py | 48 +++++++++---------- .../test_addresses_and_contacts.py | 2 +- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/frappe/contacts/doctype/contact/test_contact.py b/frappe/contacts/doctype/contact/test_contact.py index bac2503aef..82abec3b1e 100644 --- a/frappe/contacts/doctype/contact/test_contact.py +++ b/frappe/contacts/doctype/contact/test_contact.py @@ -9,31 +9,6 @@ from frappe.exceptions import ValidationError class TestContact(unittest.TestCase): - def create_contact(self, name, salutation, emails=None, phones=None, save=True): - doc = frappe.get_doc({ - "doctype": "Contact", - "first_name": name, - "status": "Open", - "salutation": salutation - }) - if emails: - for d in emails: - doc.add_email(d.get("email"), d.get("is_primary")) - - if phones: - for d in phones: - doc.add_phone(d.get("phone"), d.get("is_primary_phone"), d.get("is_primary_mobile_no")) - - if save: - doc.insert() - - return doc - - def tearDown(self): - frappe.db.sql("delete from `tabContact`") - frappe.db.sql("delete from `tabContact Phone`") - frappe.db.sql("delete from `tabContact Email`") - def test_check_default_email(self): emails = [ {"email": "test1@example.com", "is_primary": 0}, @@ -87,4 +62,25 @@ class TestContact(unittest.TestCase): self.assertRaises(ValidationError, contact_email.save) # No default set for phones if many phones are passed as params - self.assertRaises(ValidationError, contact_phone.save) \ No newline at end of file + self.assertRaises(ValidationError, contact_phone.save) + +def create_contact(name, salutation, emails=None, phones=None, save=True): + doc = frappe.get_doc({ + "doctype": "Contact", + "first_name": name, + "status": "Open", + "salutation": salutation + }) + + if emails: + for d in emails: + doc.add_email(d.get("email"), d.get("is_primary")) + + if phones: + for d in phones: + doc.add_phone(d.get("phone"), d.get("is_primary_phone"), d.get("is_primary_mobile_no")) + + if save: + doc.insert() + + return doc \ No newline at end of file diff --git a/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py b/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py index 434d138a6c..47e1c28e8b 100644 --- a/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py +++ b/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py @@ -83,7 +83,7 @@ def create_linked_contact(link_list, address): "status": "Open" }) contact.add_email("test_contact@example.com") - contact.add_phone("+91 0000000000") + contact.add_phone("+91 0000000000", is_primary_phone=True) for name in link_list: contact.append("links",{