diff --git a/.travis.yml b/.travis.yml index 8a4f7cd..c72af26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/authorize/apis/__init__.py b/authorize/apis/__init__.py index e69de29..519ff49 100644 --- a/authorize/apis/__init__.py +++ b/authorize/apis/__init__.py @@ -0,0 +1 @@ +from __future__ import unicode_literals \ No newline at end of file diff --git a/authorize/apis/authorize_api.py b/authorize/apis/authorize_api.py index 9b27d96..c57add0 100644 --- a/authorize/apis/authorize_api.py +++ b/authorize/apis/authorize_api.py @@ -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 @@ -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 diff --git a/authorize/apis/base_api.py b/authorize/apis/base_api.py index 2dc30ac..1176244 100644 --- a/authorize/apis/base_api.py +++ b/authorize/apis/base_api.py @@ -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 diff --git a/authorize/apis/recurring_api.py b/authorize/apis/recurring_api.py index 9c01982..617126e 100644 --- a/authorize/apis/recurring_api.py +++ b/authorize/apis/recurring_api.py @@ -93,8 +93,8 @@ def _make_xml(self, method, subscription_id=None, params={}): 'last_name': '' } } - - 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'])) diff --git a/authorize/response_parser.py b/authorize/response_parser.py index 3cb45c7..c95da2f 100644 --- a/authorize/response_parser.py +++ b/authorize/response_parser.py @@ -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) diff --git a/docs/development.rst b/docs/development.rst index 72b4a62..7c71095 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -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/ diff --git a/requirements.txt b/requirements.txt index 470b73b..50ce9d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ colander>=1.0b1 -unittest2==0.5.1 -sphinx==1.1.3 \ No newline at end of file diff --git a/setup.py b/setup.py index 7227152..19dd3d3 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='Py-Authorize', - version='1.1.0.0', + version='1.2.0.0', author='Vincent Catalano', author_email='vincent@vincentcatlano.com', url='https://github.com/vcatalano/py-authorize', @@ -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', diff --git a/tests/test_address_api.py b/tests/test_address_api.py index 43a2848..4273d63 100644 --- a/tests/test_address_api.py +++ b/tests/test_address_api.py @@ -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', @@ -16,7 +16,7 @@ 'fax_number': '520-456-7890', } -CREATE_ADDRESS_REQUEST = u''' +CREATE_ADDRESS_REQUEST = ''' @@ -38,7 +38,7 @@ ''' -DETAILS_ADDRESS_REQUEST = u''' +DETAILS_ADDRESS_REQUEST = ''' @@ -49,7 +49,7 @@ 0987654321 ''' -UPDATE_ADDRESS_REQUEST = u''' +UPDATE_ADDRESS_REQUEST = ''' @@ -72,7 +72,7 @@ ''' -DELETE_ADDRESS_REQUEST = u''' +DELETE_ADDRESS_REQUEST = ''' diff --git a/tests/test_bank_account_api.py b/tests/test_bank_account_api.py index 2b4ae28..a30e2a1 100644 --- a/tests/test_bank_account_api.py +++ b/tests/test_bank_account_api.py @@ -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', @@ -47,7 +47,7 @@ }, } -CREATE_BANK_ACCOUNT_REQUEST = u''' +CREATE_BANK_ACCOUNT_REQUEST = ''' @@ -82,7 +82,7 @@ ''' -DETAILS_BANK_ACCOUNT_REQUEST = u''' +DETAILS_BANK_ACCOUNT_REQUEST = ''' @@ -93,7 +93,7 @@ 0987654321 ''' -UPDATE_BANK_ACCOUNT_REQUEST = u''' +UPDATE_BANK_ACCOUNT_REQUEST = ''' @@ -129,7 +129,7 @@ ''' -DELETE_BANK_ACCOUNT_REQUEST = u''' +DELETE_BANK_ACCOUNT_REQUEST = ''' diff --git a/tests/test_batch_api.py b/tests/test_batch_api.py index 3d8ba50..6407053 100644 --- a/tests/test_batch_api.py +++ b/tests/test_batch_api.py @@ -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 = ''' @@ -21,7 +21,7 @@ ''' -LIST_BATCH_REQUEST = u''' +LIST_BATCH_REQUEST = ''' diff --git a/tests/test_credit_card_api.py b/tests/test_credit_card_api.py index 4ddd4c6..9ed4e6e 100644 --- a/tests/test_credit_card_api.py +++ b/tests/test_credit_card_api.py @@ -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', @@ -29,7 +29,7 @@ 'validation_mode': 'testMode', } -CREATE_CREDIT_CARD_REQUEST = u''' +CREATE_CREDIT_CARD_REQUEST = ''' @@ -62,7 +62,7 @@ ''' -DETAILS_CREDIT_CARD_REQUEST = u''' +DETAILS_CREDIT_CARD_REQUEST = ''' @@ -74,7 +74,7 @@ ''' -UPDATE_CREDIT_CARD_REQUEST = u''' +UPDATE_CREDIT_CARD_REQUEST = ''' @@ -108,7 +108,7 @@ ''' -DELETE_CREDIT_CARD_REQUEST = u''' +DELETE_CREDIT_CARD_REQUEST = ''' @@ -120,7 +120,7 @@ ''' -VALIDATE_CREDIT_CARD_REQUEST = u''' +VALIDATE_CREDIT_CARD_REQUEST = ''' diff --git a/tests/test_customer_api.py b/tests/test_customer_api.py index d0bccd4..a501993 100644 --- a/tests/test_customer_api.py +++ b/tests/test_customer_api.py @@ -1,7 +1,7 @@ from authorize import Configuration from authorize.xml_data import prettify -from unittest2 import TestCase +from unittest import TestCase CREATE_CUSTOMER = { @@ -48,7 +48,7 @@ 'customer_type': 'individual', } -CREATE_CUSTOMER_REQUEST = u''' +CREATE_CUSTOMER_REQUEST = ''' @@ -98,7 +98,7 @@ ''' -CUSTOMER_DETAILS_REQUEST = u''' +CUSTOMER_DETAILS_REQUEST = ''' @@ -109,7 +109,7 @@ ''' -CUSTOMER_UPDATE_REQUEST = u''' +CUSTOMER_UPDATE_REQUEST = ''' @@ -125,7 +125,7 @@ ''' -CUSTOMER_DELETE_REQUEST = u''' +CUSTOMER_DELETE_REQUEST = ''' diff --git a/tests/test_live_address.py b/tests/test_live_address.py index 6a39276..9c8eaf4 100644 --- a/tests/test_live_address.py +++ b/tests/test_live_address.py @@ -4,7 +4,7 @@ from nose.plugins.attrib import attr -from unittest2 import TestCase +from unittest import TestCase ADDRESS = { 'first_name': 'Rob', diff --git a/tests/test_live_bank_account.py b/tests/test_live_bank_account.py index 36d4491..419fed9 100644 --- a/tests/test_live_bank_account.py +++ b/tests/test_live_bank_account.py @@ -4,7 +4,7 @@ from nose.plugins.attrib import attr -from unittest2 import TestCase +from unittest import TestCase BANK_ACCOUNT = { 'routing_number': '322271627', diff --git a/tests/test_live_batch.py b/tests/test_live_batch.py index 317eebf..4c35568 100644 --- a/tests/test_live_batch.py +++ b/tests/test_live_batch.py @@ -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', diff --git a/tests/test_live_credit_card.py b/tests/test_live_credit_card.py index 8fc4ea0..70515db 100644 --- a/tests/test_live_credit_card.py +++ b/tests/test_live_credit_card.py @@ -6,7 +6,7 @@ from nose.plugins.attrib import attr -from unittest2 import TestCase +from unittest import TestCase CREDIT_CARD = { 'card_number': '4111111111111111', diff --git a/tests/test_live_customer.py b/tests/test_live_customer.py index c253be6..b02fcb7 100644 --- a/tests/test_live_customer.py +++ b/tests/test_live_customer.py @@ -5,7 +5,7 @@ from nose.plugins.attrib import attr -from unittest2 import TestCase +from unittest import TestCase FULL_CUSTOMER = { 'email': 'vincent@vincentcatalano.com', diff --git a/tests/test_live_recurring.py b/tests/test_live_recurring.py index 79084d6..52433e9 100644 --- a/tests/test_live_recurring.py +++ b/tests/test_live_recurring.py @@ -7,7 +7,7 @@ from nose.plugins.attrib import attr -from unittest2 import TestCase +from unittest import TestCase BASIC_RECURRING = { 'interval_length': 14, diff --git a/tests/test_live_transaction.py b/tests/test_live_transaction.py index 051935f..02dfef8 100644 --- a/tests/test_live_transaction.py +++ b/tests/test_live_transaction.py @@ -8,7 +8,7 @@ from nose.plugins.attrib import attr -from unittest2 import TestCase +from unittest import TestCase FULL_CARD_TRANSACTION = { 'credit_card': { diff --git a/tests/test_recurring_api.py b/tests/test_recurring_api.py index 3dd83d0..0748c10 100644 --- a/tests/test_recurring_api.py +++ b/tests/test_recurring_api.py @@ -3,7 +3,7 @@ from datetime import date -from unittest2 import TestCase +from unittest import TestCase CREATE_RECURRING = { @@ -94,7 +94,7 @@ }, } -CREATE_RECURRING_REQUEST = u''' +CREATE_RECURRING_REQUEST = ''' @@ -153,7 +153,7 @@ '''.format(date.today().isoformat()) -DETAILS_RECURRING_REQUEST = u''' +DETAILS_RECURRING_REQUEST = ''' @@ -164,7 +164,7 @@ ''' -UPDATE_RECURRING_REQUEST = u''' +UPDATE_RECURRING_REQUEST = ''' @@ -220,7 +220,7 @@ '''.format(date.today().isoformat()) -DELETE_RECURRING_REQUEST = u''' +DELETE_RECURRING_REQUEST = ''' diff --git a/tests/test_response_parser.py b/tests/test_response_parser.py index 739c918..5764abd 100644 --- a/tests/test_response_parser.py +++ b/tests/test_response_parser.py @@ -1,11 +1,11 @@ import xml.etree.cElementTree as E -from unittest2 import TestCase +from unittest import TestCase from authorize.response_parser import parse_response -SINGLE_LIST_ITEM_RESPONSE_XML = u''' +SINGLE_LIST_ITEM_RESPONSE_XML = ''' @@ -18,7 +18,7 @@ ''' -MULTIPLE_LIST_ITEM_RESPONSE_XML = u''' +MULTIPLE_LIST_ITEM_RESPONSE_XML = ''' @@ -38,7 +38,7 @@ ''' -NUMERIC_STRING_LIST_RESPONSE_XML = u''' +NUMERIC_STRING_LIST_RESPONSE_XML = ''' @@ -59,7 +59,7 @@ ''' -DIRECT_RESPONSE_XML = u''' +DIRECT_RESPONSE_XML = ''' diff --git a/tests/test_schemas.py b/tests/test_schemas.py index dd31c86..b262cc9 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -5,7 +5,7 @@ from colander import Invalid from datetime import date -from unittest2 import TestCase +from unittest import TestCase ADDRESS = { 'first_name': 'Rob', diff --git a/tests/test_transaction_api.py b/tests/test_transaction_api.py index dd83906..befd2e8 100644 --- a/tests/test_transaction_api.py +++ b/tests/test_transaction_api.py @@ -1,7 +1,7 @@ from authorize import Configuration from authorize.xml_data import prettify -from unittest2 import TestCase +from unittest import TestCase FULL_CIM_TRANSACTION = { 'amount': 30.00, @@ -145,7 +145,7 @@ 'last_four': '1111', } -CIM_SALE_REQUEST = u''' +CIM_SALE_REQUEST = ''' @@ -209,7 +209,7 @@ ''' -AIM_SALE_REQUEST = u''' +AIM_SALE_REQUEST = ''' @@ -303,7 +303,7 @@ ''' -SETTLE_REQUEST = u''' +SETTLE_REQUEST = ''' @@ -317,7 +317,7 @@ ''' -REFUND_REQUEST = u''' +REFUND_REQUEST = ''' @@ -338,7 +338,7 @@ ''' -VOID_REQUEST = u''' +VOID_REQUEST = ''' @@ -352,7 +352,7 @@ ''' -DETAILS_REQUEST = u''' +DETAILS_REQUEST = ''' @@ -363,7 +363,7 @@ ''' -UNSETTLED_LIST_REQUEST = u''' +UNSETTLED_LIST_REQUEST = ''' @@ -373,7 +373,7 @@ ''' -SETTLED_LIST_REQUEST = u''' +SETTLED_LIST_REQUEST = ''' diff --git a/tests/test_xml_data.py b/tests/test_xml_data.py index 4f9a50a..2387c46 100644 --- a/tests/test_xml_data.py +++ b/tests/test_xml_data.py @@ -1,5 +1,5 @@ from authorize.xml_data import * -from unittest2 import TestCase +from unittest import TestCase PROFILE = { 'merchant_id': '1234567890', @@ -79,7 +79,7 @@ 'description': 'Just another invoice...', } -CREATE_PROFILE_XML = u''' +CREATE_PROFILE_XML = ''' 1234567890 @@ -88,7 +88,7 @@ ''' -CREATE_ADDRESS_XML = u''' +CREATE_ADDRESS_XML = ''' Rob @@ -104,7 +104,7 @@ ''' -CREATE_CARD_XML = u''' +CREATE_CARD_XML = ''' 4111111111111111 @@ -113,7 +113,7 @@ ''' -CREATE_ACCOUNT_XML = u''' +CREATE_ACCOUNT_XML = ''' checking @@ -125,7 +125,7 @@ ''' -CREATE_LINE_ITEM_XML = u''' +CREATE_LINE_ITEM_XML = ''' CIR0001 @@ -137,7 +137,7 @@ ''' -CREATE_LINE_ITEMS_XML = u''' +CREATE_LINE_ITEMS_XML = ''' @@ -167,7 +167,7 @@ ''' -CREATE_AMOUNT_TYPE_XML = u''' +CREATE_AMOUNT_TYPE_XML = ''' 45.00 @@ -176,7 +176,7 @@ ''' -CREATE_ORDER_XML = u''' +CREATE_ORDER_XML = ''' INV0001