Skip to content

Commit f8934cd

Browse files
committed
Merge branch 'jtharris-py3k'
2 parents f1f133d + 7aba8a7 commit f8934cd

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ docs/build
55
build/
66
dist/
77
settings_local.py
8+
env/
9+
.idea/

pyavatax/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
22
import logging
33
import json
4+
import six
45

56
import requests
67
from pyavatax.django_integration import get_django_recorder
@@ -9,12 +10,11 @@
910
def str_to_class(klassname):
1011
"""Returns class of string parameter. Requires class to be in module namespace"""
1112
import sys
12-
import types
1313
try:
1414
identifier = getattr(sys.modules[__name__], klassname)
1515
except AttributeError:
1616
raise NameError("%s doesn't exist." % klassname)
17-
if isinstance(identifier, (types.ClassType, types.TypeType)):
17+
if isinstance(identifier, six.class_types):
1818
return identifier
1919
raise TypeError("%s is not a class." % klassname)
2020

@@ -95,7 +95,7 @@ def _invalid_field(self, field):
9595

9696
def update(self, *args, **kwargs):
9797
"""Updates kwargs onto attributes of self"""
98-
for k, v in kwargs.iteritems():
98+
for k, v in six.iteritems(kwargs):
9999
if k in self._fields:
100100
setattr(self, k, v)
101101
elif k in self._has: # has an object
@@ -758,7 +758,7 @@ class TaxAddresses(AvalaraBase):
758758

759759
class TaxDetails(AvalaraBase):
760760
"""Represents TaxDetails response from Avalara"""
761-
_fields = ['Country', 'Region', 'JurisType', 'Taxable', 'Rate', 'Tax', 'JurisName', 'TaxName']
761+
_fields = ['Country', 'Region', 'JurisType', 'JurisCode', 'Taxable', 'Rate', 'Tax', 'JurisName', 'TaxName']
762762

763763

764764
class TaxLines(AvalaraBase):

requirements.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# if you use pip to do installations, these are the dependencies
22

3-
requests==1.1 # for all http connection
3+
requests==2.5.3 # for all http connection
44
decorator==3.4.0 # to preserve introspection funcsig integrity
5-
suds==0.4
5+
suds-jurko==0.6
6+
six==1.9.0
67
# tests are run with pytest, fixtures for tests as well, Sphinx for documentation
7-
pytest==2.2.4
8-
testfixtures==2.3.5
8+
pytest==2.6.4
9+
testfixtures==4.1.2
910
Sphinx==1.1.3
1011
simplejson==3.3.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
author = 'John Obelenus',
1111
author_email = '[email protected]',
1212
version=version,
13-
install_requires = ['requests==1.1', 'decorator==3.4.0', 'suds==0.4'],
13+
install_requires = ['requests==2.5.3', 'decorator==3.4.0', 'suds-jurko==0.6', 'six==1.9.0'],
1414
package_data = {
1515
'': ['*.txt', '*.rst', '*.md']
1616
},

test_avalara.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import datetime
55
import pytest
66
import uuid
7+
import six
78
from testfixtures import LogCapture
89

910

@@ -110,18 +111,18 @@ def test_discount_from_data_example():
110111
],
111112
'DocCode': uuid.uuid4().hex,
112113
'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},
118119
],
119120
'DocType': 'SalesOrder',
120121
'Discount': str(amount),
121122
'CustomerCode': '[email protected]'
122123
}
123124
tax = api.post_tax(data, commit=True)
124-
print tax.error
125+
six.print_(tax.error)
125126
assert tax.is_success is True
126127
assert float(tax.TotalTax) == 0
127128
assert float(tax.TotalAmount) == amount
@@ -304,23 +305,18 @@ def test_posttax():
304305

305306
@pytest.mark.logging
306307
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
324320

325321

326322
@pytest.mark.post_tax
@@ -539,7 +535,7 @@ def test_bad_json():
539535
import simplejson
540536
def fn():
541537
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}
543539
stem = '/'.join([api.VERSION, 'tax', 'get'])
544540
resp = api._post(stem, data)
545541
tax_resp = PostTaxResponse(resp)

0 commit comments

Comments
 (0)