blob: d7b60daa37b819843325d4caf2db15cfb11d9660 [file] [log] [blame]
Aditya Hasef3c22f32019-01-22 18:22:20 +05301from __future__ import unicode_literals
Chillar Anand915b3432021-09-02 16:44:59 +05302
tundebabzy40a02762017-10-25 07:54:34 +01003import unittest
Chillar Anand915b3432021-09-02 16:44:59 +05304
tundebabzy40a02762017-10-25 07:54:34 +01005from frappe.test_runner import make_test_objects
6
Chillar Anand915b3432021-09-02 16:44:59 +05307from erpnext.accounts.party import get_party_shipping_address
8
tundebabzy40a02762017-10-25 07:54:34 +01009
10class TestUtils(unittest.TestCase):
11 @classmethod
12 def setUpClass(cls):
13 super(TestUtils, cls).setUpClass()
14 make_test_objects('Address', ADDRESS_RECORDS)
15
16 def test_get_party_shipping_address(self):
17 address = get_party_shipping_address('Customer', '_Test Customer 1')
18 self.assertEqual(address, '_Test Billing Address 2 Title-Billing')
19
20 def test_get_party_shipping_address2(self):
21 address = get_party_shipping_address('Customer', '_Test Customer 2')
22 self.assertEqual(address, '_Test Shipping Address 2 Title-Shipping')
23
24
25ADDRESS_RECORDS = [
26 {
27 "doctype": "Address",
28 "address_type": "Billing",
29 "address_line1": "Address line 1",
30 "address_title": "_Test Billing Address Title",
31 "city": "Lagos",
32 "country": "Nigeria",
33 "links": [
34 {
35 "link_doctype": "Customer",
36 "link_name": "_Test Customer 2",
37 "doctype": "Dynamic Link"
38 }
39 ]
40 },
41 {
42 "doctype": "Address",
43 "address_type": "Shipping",
44 "address_line1": "Address line 2",
45 "address_title": "_Test Shipping Address 1 Title",
46 "city": "Lagos",
47 "country": "Nigeria",
48 "links": [
49 {
50 "link_doctype": "Customer",
51 "link_name": "_Test Customer 2",
52 "doctype": "Dynamic Link"
53 }
54 ]
55 },
56 {
57 "doctype": "Address",
58 "address_type": "Shipping",
59 "address_line1": "Address line 3",
60 "address_title": "_Test Shipping Address 2 Title",
61 "city": "Lagos",
62 "country": "Nigeria",
63 "is_shipping_address": "1",
64 "links": [
65 {
66 "link_doctype": "Customer",
67 "link_name": "_Test Customer 2",
68 "doctype": "Dynamic Link"
69 }
70 ]
71 },
72 {
73 "doctype": "Address",
74 "address_type": "Billing",
75 "address_line1": "Address line 4",
76 "address_title": "_Test Billing Address 2 Title",
77 "city": "Lagos",
78 "country": "Nigeria",
79 "is_shipping_address": "1",
80 "links": [
81 {
82 "link_doctype": "Customer",
83 "link_name": "_Test Customer 1",
84 "doctype": "Dynamic Link"
85 }
86 ]
87 }
88]