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