Aditya Hase | f3c22f3 | 2019-01-22 18:22:20 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 2 | |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 3 | import unittest |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 4 | |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 5 | from frappe.test_runner import make_test_objects |
| 6 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 7 | from erpnext.accounts.party import get_party_shipping_address |
| 8 | |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 9 | |
| 10 | class 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 | |
| 25 | ADDRESS_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 | ] |