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