|
4 | 4 | import datetime
|
5 | 5 | import pytest
|
6 | 6 | import uuid
|
| 7 | +import six |
7 | 8 | from testfixtures import LogCapture
|
8 | 9 |
|
9 | 10 |
|
@@ -110,18 +111,18 @@ def test_discount_from_data_example():
|
110 | 111 | ],
|
111 | 112 | 'DocCode': uuid.uuid4().hex,
|
112 | 113 | 'Lines': [
|
113 |
| - {'ItemCode': 'canon-eos-1dc', 'Discounted': True, 'LineNo': 1, 'DestinationCode': 2, 'Description': u'Canon EOS 1DC', 'Qty': 1L, 'Amount': 667.0, 'OriginCode': 1}, |
114 |
| - {'ItemCode': 'canon-24-70-f28l-ii', 'Discounted': True, 'LineNo': 2, 'DestinationCode': 2, 'Description': u'Canon 24-70 f/2.8L II', 'Qty': 1L, 'Amount': 111.0, 'OriginCode': 1}, |
115 |
| - {'ItemCode': 'sandisk-extreme-pro-cf-128gb', 'Discounted': True, 'LineNo': 3, 'DestinationCode': 2, 'Description': u'SanDisk Extreme Pro CF 128GB', 'Qty': 1L, 'Amount': 83.0, 'OriginCode': 1}, |
116 |
| - {'ItemCode': 'westcott-icelight', 'Discounted': True, 'LineNo': 4, 'DestinationCode': 2, 'Description': u'Westcott IceLight', 'Qty': 1L, 'Amount': 44.0, 'OriginCode': 1}, |
117 |
| - {'ItemCode': 'sennheiser-mke-400-camera-mic', 'Discounted': True, 'LineNo': 5, 'DestinationCode': 2, 'Description': u'Sennheiser MKE 400 On-Camera Mic', 'Qty': 1L, 'Amount': 53.5, 'OriginCode': 1}, |
| 114 | + {'ItemCode': 'canon-eos-1dc', 'Discounted': True, 'LineNo': 1, 'DestinationCode': 2, 'Description': u'Canon EOS 1DC', 'Qty': 1, 'Amount': 667.0, 'OriginCode': 1}, |
| 115 | + {'ItemCode': 'canon-24-70-f28l-ii', 'Discounted': True, 'LineNo': 2, 'DestinationCode': 2, 'Description': u'Canon 24-70 f/2.8L II', 'Qty': 1, 'Amount': 111.0, 'OriginCode': 1}, |
| 116 | + {'ItemCode': 'sandisk-extreme-pro-cf-128gb', 'Discounted': True, 'LineNo': 3, 'DestinationCode': 2, 'Description': u'SanDisk Extreme Pro CF 128GB', 'Qty': 1, 'Amount': 83.0, 'OriginCode': 1}, |
| 117 | + {'ItemCode': 'westcott-icelight', 'Discounted': True, 'LineNo': 4, 'DestinationCode': 2, 'Description': u'Westcott IceLight', 'Qty': 1, 'Amount': 44.0, 'OriginCode': 1}, |
| 118 | + {'ItemCode': 'sennheiser-mke-400-camera-mic', 'Discounted': True, 'LineNo': 5, 'DestinationCode': 2, 'Description': u'Sennheiser MKE 400 On-Camera Mic', 'Qty': 1, 'Amount': 53.5, 'OriginCode': 1}, |
118 | 119 | ],
|
119 | 120 | 'DocType': 'SalesOrder',
|
120 | 121 | 'Discount': str(amount),
|
121 | 122 | 'CustomerCode': '[email protected]'
|
122 | 123 | }
|
123 | 124 | tax = api.post_tax(data, commit=True)
|
124 |
| - print tax.error |
| 125 | + six.print_(tax.error) |
125 | 126 | assert tax.is_success is True
|
126 | 127 | assert float(tax.TotalTax) == 0
|
127 | 128 | assert float(tax.TotalAmount) == amount
|
@@ -304,23 +305,18 @@ def test_posttax():
|
304 | 305 |
|
305 | 306 | @pytest.mark.logging
|
306 | 307 | def test_timeout():
|
307 |
| - with LogCapture('pyavatax.api') as l: |
308 |
| - api = get_api(timeout=0.00001) |
309 |
| - lat = 47.627935 |
310 |
| - lng = -122.51702 |
311 |
| - line = Line(Amount=10.00) |
312 |
| - doc = Document() |
313 |
| - doc.add_line(line) |
314 |
| - try: |
315 |
| - api.get_tax(lat, lng, doc) |
316 |
| - except AvalaraServerNotReachableException: |
317 |
| - assert True |
318 |
| - else: |
319 |
| - assert False |
320 |
| - l.check( |
321 |
| - ('pyavatax.api', 'DEBUG', 'None inserting LineNo 1'), |
322 |
| - ('pyavatax.api', 'WARNING', "HTTPSConnectionPool(host='development.avalara.net', port=443): Request timed out. (timeout=1e-05)") |
323 |
| - ) |
| 308 | + api = get_api(timeout=0.00001) |
| 309 | + lat = 47.627935 |
| 310 | + lng = -122.51702 |
| 311 | + line = Line(Amount=10.00) |
| 312 | + doc = Document() |
| 313 | + doc.add_line(line) |
| 314 | + try: |
| 315 | + api.get_tax(lat, lng, doc) |
| 316 | + except AvalaraServerNotReachableException: |
| 317 | + assert True |
| 318 | + else: |
| 319 | + assert False |
324 | 320 |
|
325 | 321 |
|
326 | 322 | @pytest.mark.post_tax
|
@@ -539,7 +535,7 @@ def test_bad_json():
|
539 | 535 | import simplejson
|
540 | 536 | def fn():
|
541 | 537 | api = get_api()
|
542 |
| - data = {'Addresses': [{'City': u'Chicago', 'Country': 'US', 'Region': u'IL', 'Line2': u'', 'Line1': u'516 N Ogden Ave\r\nMailroom', 'PostalCode': u'60642', 'AddressCode': 2}, {'City': 'Concord', 'Country': 'US', 'Region': 'MA', 'Line2': '', 'Line1': '130B Baker Avenue Extension', 'PostalCode': '01742', 'AddressCode': 1}], 'DocCode': 'adoccode', 'Lines': [{'LineNo': 1, 'DestinationCode': 2, 'Description': u'Product 1', 'Qty': 1L, 'Amount': '161.00', 'OriginCode': 1}], 'DocType': 'SalesOrder', 'CustomerCode': 21051} |
| 538 | + data = {'Addresses': [{'City': u'Chicago', 'Country': 'US', 'Region': u'IL', 'Line2': u'', 'Line1': u'516 N Ogden Ave\r\nMailroom', 'PostalCode': u'60642', 'AddressCode': 2}, {'City': 'Concord', 'Country': 'US', 'Region': 'MA', 'Line2': '', 'Line1': '130B Baker Avenue Extension', 'PostalCode': '01742', 'AddressCode': 1}], 'DocCode': 'adoccode', 'Lines': [{'LineNo': 1, 'DestinationCode': 2, 'Description': u'Product 1', 'Qty': 1, 'Amount': '161.00', 'OriginCode': 1}], 'DocType': 'SalesOrder', 'CustomerCode': 21051} |
543 | 539 | stem = '/'.join([api.VERSION, 'tax', 'get'])
|
544 | 540 | resp = api._post(stem, data)
|
545 | 541 | tax_resp = PostTaxResponse(resp)
|
|
0 commit comments