Skip to content

Commit

Permalink
Adding Python 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
vcatalano committed Mar 21, 2014
1 parent ecb261c commit b59e392
Show file tree
Hide file tree
Showing 26 changed files with 88 additions and 79 deletions.
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
language: python

python:
- "2.7"
# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script: nosetests
- 2.7
- 3.2
- 3.3
- 3.4

install:
- pip install -r requirements.txt

script:
- nosetests
1 change: 1 addition & 0 deletions authorize/apis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import unicode_literals
8 changes: 5 additions & 3 deletions authorize/apis/authorize_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import urllib2
import xml.etree.cElementTree as E

from urllib2 import HTTPError
try:
import urllib.request as urllib2
except:
import urllib2

from authorize.apis.address_api import AddressAPI
from authorize.apis.credit_card_api import CreditCardAPI
Expand Down Expand Up @@ -55,7 +57,7 @@ def _make_call(self, call):
response = urllib2.urlopen(request).read()
response = E.fromstring(response)
result = parse_response(response)
except HTTPError, e:
except urllib2.HTTPError:
return AuthorizeConnectionError('Error processing XML request.')

# Throw an exception for invalid calls. This makes error handling
Expand Down
2 changes: 1 addition & 1 deletion authorize/apis/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def __init__(self, api):
def _deserialize(self, schema, params={}):
try:
deserialized = schema.deserialize(params)
except colander.Invalid, e:
except colander.Invalid as e:
raise AuthorizeInvalidError(e)
return deserialized
4 changes: 2 additions & 2 deletions authorize/apis/recurring_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def _make_xml(self, method, subscription_id=None, params={}):
'last_name': '<empty>'
}
}

params = dict(arb_required_fields.items() + params.items())
arb_required_fields.update(params)
params = arb_required_fields

if 'billing' in params:
subscription.append(create_address('billTo', params['billing']))
Expand Down
4 changes: 2 additions & 2 deletions authorize/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def parse_response(element):
dict_items = [new_item]
elif key in LIST_FIELDS:
key = rename(key)
if hasattr(dict_items, key):
try:
dict_items[key].append(new_item)
else:
except:
dict_items[key] = [new_item]
else:
key = rename(key)
Expand Down
2 changes: 0 additions & 2 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ Additionally, you will need to install the following dependencies for running
test and compiling documentation.

- nose_
- unittest2_
- sphinx_ (for documentation)

.. _Github page: https://github.com/vcatalano/py-authorize
.. _nose: https://nose.readthedocs.org/en/latest/
.. _unittest2: https://pypi.python.org/pypi/unittest2
.. _sphinx: http://sphinx-doc.org/


Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
colander>=1.0b1
unittest2==0.5.1
sphinx==1.1.3
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='Py-Authorize',
version='1.1.0.0',
version='1.2.0.0',
author='Vincent Catalano',
author_email='[email protected]',
url='https://github.com/vcatalano/py-authorize',
Expand All @@ -22,7 +22,11 @@
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'License :: OSI Approved :: MIT License',
'Topic :: Office/Business :: Financial',
'Topic :: Internet :: WWW/HTTP',
Expand Down
10 changes: 5 additions & 5 deletions tests/test_address_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from authorize import Configuration
from authorize.xml_data import prettify

from unittest2 import TestCase
from unittest import TestCase

ADDRESS = {
'first_name': 'Rob',
Expand All @@ -16,7 +16,7 @@
'fax_number': '520-456-7890',
}

CREATE_ADDRESS_REQUEST = u'''
CREATE_ADDRESS_REQUEST = '''
<?xml version="1.0" ?>
<createCustomerShippingAddressRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -38,7 +38,7 @@
</address>
</createCustomerShippingAddressRequest>'''

DETAILS_ADDRESS_REQUEST = u'''
DETAILS_ADDRESS_REQUEST = '''
<?xml version="1.0" ?>
<getCustomerShippingAddressRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -49,7 +49,7 @@
<customerAddressId>0987654321</customerAddressId>
</getCustomerShippingAddressRequest>'''

UPDATE_ADDRESS_REQUEST = u'''
UPDATE_ADDRESS_REQUEST = '''
<?xml version="1.0" ?>
<updateCustomerShippingAddressRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -72,7 +72,7 @@
</address>
</updateCustomerShippingAddressRequest>'''

DELETE_ADDRESS_REQUEST = u'''
DELETE_ADDRESS_REQUEST = '''
<?xml version="1.0" ?>
<deleteCustomerShippingAddressRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down
10 changes: 5 additions & 5 deletions tests/test_bank_account_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from authorize import Configuration
from authorize.xml_data import prettify

from unittest2 import TestCase
from unittest import TestCase

CREATE_BANK_ACCOUNT = {
'customer_type': 'individual',
Expand Down Expand Up @@ -47,7 +47,7 @@
},
}

CREATE_BANK_ACCOUNT_REQUEST = u'''
CREATE_BANK_ACCOUNT_REQUEST = '''
<?xml version="1.0" ?>
<createCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down Expand Up @@ -82,7 +82,7 @@
</paymentProfile>
</createCustomerPaymentProfileRequest>'''

DETAILS_BANK_ACCOUNT_REQUEST = u'''
DETAILS_BANK_ACCOUNT_REQUEST = '''
<?xml version="1.0" ?>
<getCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -93,7 +93,7 @@
<customerPaymentProfileId>0987654321</customerPaymentProfileId>
</getCustomerPaymentProfileRequest>'''

UPDATE_BANK_ACCOUNT_REQUEST = u'''
UPDATE_BANK_ACCOUNT_REQUEST = '''
<?xml version="1.0" ?>
<updateCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down Expand Up @@ -129,7 +129,7 @@
</paymentProfile>
</updateCustomerPaymentProfileRequest>'''

DELETE_BANK_ACCOUNT_REQUEST = u'''
DELETE_BANK_ACCOUNT_REQUEST = '''
<?xml version="1.0" ?>
<deleteCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down
6 changes: 3 additions & 3 deletions tests/test_batch_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from authorize import Configuration
from authorize.xml_data import prettify

from unittest2 import TestCase
from unittest import TestCase

LIST_BATCH_DATES = {
'start': datetime.datetime(2012, 5, 1), #'2012-05-01T00:00:00'
'end': datetime.datetime(2012, 5, 31), #'2012-05-31T00:00:00'
}

BATCH_DETAILS_REQUEST = u'''
BATCH_DETAILS_REQUEST = '''
<?xml version="1.0" ?>
<getBatchStatisticsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -21,7 +21,7 @@
</getBatchStatisticsRequest>
'''

LIST_BATCH_REQUEST = u'''
LIST_BATCH_REQUEST = '''
<?xml version="1.0" ?>
<getSettledBatchListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down
12 changes: 6 additions & 6 deletions tests/test_credit_card_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from authorize.configuration import Configuration
from authorize.xml_data import prettify

from unittest2 import TestCase
from unittest import TestCase

CREDIT_CARD = {
'customer_type': 'individual',
Expand Down Expand Up @@ -29,7 +29,7 @@
'validation_mode': 'testMode',
}

CREATE_CREDIT_CARD_REQUEST = u'''
CREATE_CREDIT_CARD_REQUEST = '''
<?xml version="1.0" ?>
<createCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down Expand Up @@ -62,7 +62,7 @@
</createCustomerPaymentProfileRequest>
'''

DETAILS_CREDIT_CARD_REQUEST = u'''
DETAILS_CREDIT_CARD_REQUEST = '''
<?xml version="1.0" ?>
<getCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -74,7 +74,7 @@
</getCustomerPaymentProfileRequest>
'''

UPDATE_CREDIT_CARD_REQUEST = u'''
UPDATE_CREDIT_CARD_REQUEST = '''
<?xml version="1.0" ?>
<updateCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down Expand Up @@ -108,7 +108,7 @@
</updateCustomerPaymentProfileRequest>
'''

DELETE_CREDIT_CARD_REQUEST = u'''
DELETE_CREDIT_CARD_REQUEST = '''
<?xml version="1.0" ?>
<deleteCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -120,7 +120,7 @@
</deleteCustomerPaymentProfileRequest>
'''

VALIDATE_CREDIT_CARD_REQUEST = u'''
VALIDATE_CREDIT_CARD_REQUEST = '''
<?xml version="1.0" ?>
<validateCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down
10 changes: 5 additions & 5 deletions tests/test_customer_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from authorize import Configuration
from authorize.xml_data import prettify

from unittest2 import TestCase
from unittest import TestCase


CREATE_CUSTOMER = {
Expand Down Expand Up @@ -48,7 +48,7 @@
'customer_type': 'individual',
}

CREATE_CUSTOMER_REQUEST = u'''
CREATE_CUSTOMER_REQUEST = '''
<?xml version="1.0" ?>
<createCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down Expand Up @@ -98,7 +98,7 @@
</createCustomerProfileRequest>
'''

CUSTOMER_DETAILS_REQUEST = u'''
CUSTOMER_DETAILS_REQUEST = '''
<?xml version="1.0" ?>
<getCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -109,7 +109,7 @@
</getCustomerProfileRequest>
'''

CUSTOMER_UPDATE_REQUEST = u'''
CUSTOMER_UPDATE_REQUEST = '''
<?xml version="1.0" ?>
<updateCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand All @@ -125,7 +125,7 @@
</updateCustomerProfileRequest>
'''

CUSTOMER_DELETE_REQUEST = u'''
CUSTOMER_DELETE_REQUEST = '''
<?xml version="1.0" ?>
<deleteCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from nose.plugins.attrib import attr

from unittest2 import TestCase
from unittest import TestCase

ADDRESS = {
'first_name': 'Rob',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from nose.plugins.attrib import attr

from unittest2 import TestCase
from unittest import TestCase

BANK_ACCOUNT = {
'routing_number': '322271627',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from nose.plugins.attrib import attr

from unittest2 import TestCase
from unittest import TestCase

LIST_BATCH_DATES = {
'start': '2012-05-01',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_credit_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from nose.plugins.attrib import attr

from unittest2 import TestCase
from unittest import TestCase

CREDIT_CARD = {
'card_number': '4111111111111111',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from nose.plugins.attrib import attr

from unittest2 import TestCase
from unittest import TestCase

FULL_CUSTOMER = {
'email': '[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_recurring.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from nose.plugins.attrib import attr

from unittest2 import TestCase
from unittest import TestCase

BASIC_RECURRING = {
'interval_length': 14,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from nose.plugins.attrib import attr

from unittest2 import TestCase
from unittest import TestCase

FULL_CARD_TRANSACTION = {
'credit_card': {
Expand Down
Loading

0 comments on commit b59e392

Please sign in to comment.