diff --git a/erpnext/accounts/test/test_utils.py b/erpnext/accounts/test/test_utils.py index 77660ff442a..eddd30b68b6 100644 --- a/erpnext/accounts/test/test_utils.py +++ b/erpnext/accounts/test/test_utils.py @@ -19,11 +19,6 @@ from erpnext.tests.utils import ERPNextTestSuite class TestUtils(ERPNextTestSuite): - @classmethod - def setUpClass(cls): - super().setUpClass() - make_test_objects("Address", ADDRESS_RECORDS) - def test_get_party_shipping_address(self): address = get_party_shipping_address("Customer", "_Test Customer 1") self.assertEqual(address, "_Test Billing Address 2 Title-Billing") @@ -158,45 +153,3 @@ class TestUtils(ERPNextTestSuite): self.assertEqual(get_zero_cutoff(None), 0.005) self.assertEqual(get_zero_cutoff("EUR"), 0.005) self.assertEqual(get_zero_cutoff("BHD"), 0.0005) - - -ADDRESS_RECORDS = [ - { - "doctype": "Address", - "address_type": "Billing", - "address_line1": "Address line 1", - "address_title": "_Test Billing Address Title", - "city": "Lagos", - "country": "Nigeria", - "links": [{"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"}], - }, - { - "doctype": "Address", - "address_type": "Shipping", - "address_line1": "Address line 2", - "address_title": "_Test Shipping Address 1 Title", - "city": "Lagos", - "country": "Nigeria", - "links": [{"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"}], - }, - { - "doctype": "Address", - "address_type": "Shipping", - "address_line1": "Address line 3", - "address_title": "_Test Shipping Address 2 Title", - "city": "Lagos", - "country": "Nigeria", - "is_shipping_address": "1", - "links": [{"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"}], - }, - { - "doctype": "Address", - "address_type": "Billing", - "address_line1": "Address line 4", - "address_title": "_Test Billing Address 2 Title", - "city": "Lagos", - "country": "Nigeria", - "is_shipping_address": "1", - "links": [{"link_doctype": "Customer", "link_name": "_Test Customer 1", "doctype": "Dynamic Link"}], - }, -] diff --git a/erpnext/tests/utils.py b/erpnext/tests/utils.py index 704685b66f2..18ef2e05779 100644 --- a/erpnext/tests/utils.py +++ b/erpnext/tests/utils.py @@ -257,6 +257,7 @@ class ERPNextTestSuite(unittest.TestCase): cls.make_leads() cls.make_sales_person() cls.make_activity_type() + cls.make_address() cls.update_selling_settings() cls.update_stock_settings() cls.update_system_settings() @@ -3343,6 +3344,75 @@ class ERPNextTestSuite(unittest.TestCase): } ).insert(ignore_permissions=True) + @classmethod + def make_address(cls): + records = [ + { + "doctype": "Address", + "address_type": "Billing", + "address_line1": "Address line 1", + "address_title": "_Test Billing Address Title", + "city": "Lagos", + "country": "Nigeria", + "links": [ + {"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"} + ], + }, + { + "doctype": "Address", + "address_type": "Shipping", + "address_line1": "Address line 2", + "address_title": "_Test Shipping Address 1 Title", + "city": "Lagos", + "country": "Nigeria", + "links": [ + {"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"} + ], + }, + { + "doctype": "Address", + "address_type": "Shipping", + "address_line1": "Address line 3", + "address_title": "_Test Shipping Address 2 Title", + "city": "Lagos", + "country": "Nigeria", + "is_shipping_address": "1", + "links": [ + {"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"} + ], + }, + { + "doctype": "Address", + "address_type": "Billing", + "address_line1": "Address line 4", + "address_title": "_Test Billing Address 2 Title", + "city": "Lagos", + "country": "Nigeria", + "is_shipping_address": "1", + "links": [ + {"link_doctype": "Customer", "link_name": "_Test Customer 1", "doctype": "Dynamic Link"} + ], + }, + ] + cls.address = [] + for x in records: + if not frappe.db.exists( + "Address", + { + "address_title": x.get("address_title"), + }, + ): + cls.address.append(frappe.get_doc(x).insert()) + else: + cls.address.append( + frappe.get_doc( + "Address", + { + "address_title": x.get("address_title"), + }, + ) + ) + @contextmanager def set_user(self, user: str): try: