summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PKG-INFO6
-rw-r--r--README2
-rw-r--r--ofxhome.egg-info/PKG-INFO6
-rw-r--r--ofxhome.egg-info/SOURCES.txt4
-rw-r--r--ofxhome/__init__.py7
-rw-r--r--ofxhome/tests/__init__.py0
-rw-r--r--ofxhome/tests/test_suite.py109
-rw-r--r--setup.py6
8 files changed, 130 insertions, 10 deletions
diff --git a/PKG-INFO b/PKG-INFO
index e9bca55..daf535c 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: ofxhome
-Version: 0.3.1
+Version: 0.3.2
Summary: ofxhome.com financial institution lookup REST client
Home-page: https://github.com/captin411/ofxhome
Author: David Bartle
@@ -25,6 +25,7 @@ Description: ofxhome
example
=======
+ ```python
from ofxhome import OFXHome
s = OFXHome.search("USAA")
@@ -36,6 +37,7 @@ Description: ofxhome
bank = OFXHome.lookup(item.id)
print bank.name _ bank.fid _ bank.url _ bank.brokerid # OR
print bank['name'] _ bank['fid'] _ bank['url'] _ bank['brokerid']
+ ```
Keywords: ofx,Open Financial Exchange,bank search,ofxhome,ofxhome.com
Platform: UNKNOWN
diff --git a/README b/README
index 417956d..8305a2b 100644
--- a/README
+++ b/README
@@ -17,6 +17,7 @@ ofxclient - a python API that downloads transactions from banks
example
=======
+```python
from ofxhome import OFXHome
s = OFXHome.search("USAA")
@@ -28,3 +29,4 @@ for item in s:
bank = OFXHome.lookup(item.id)
print bank.name _ bank.fid _ bank.url _ bank.brokerid # OR
print bank['name'] _ bank['fid'] _ bank['url'] _ bank['brokerid']
+```
diff --git a/ofxhome.egg-info/PKG-INFO b/ofxhome.egg-info/PKG-INFO
index e9bca55..daf535c 100644
--- a/ofxhome.egg-info/PKG-INFO
+++ b/ofxhome.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: ofxhome
-Version: 0.3.1
+Version: 0.3.2
Summary: ofxhome.com financial institution lookup REST client
Home-page: https://github.com/captin411/ofxhome
Author: David Bartle
@@ -25,6 +25,7 @@ Description: ofxhome
example
=======
+ ```python
from ofxhome import OFXHome
s = OFXHome.search("USAA")
@@ -36,6 +37,7 @@ Description: ofxhome
bank = OFXHome.lookup(item.id)
print bank.name _ bank.fid _ bank.url _ bank.brokerid # OR
print bank['name'] _ bank['fid'] _ bank['url'] _ bank['brokerid']
+ ```
Keywords: ofx,Open Financial Exchange,bank search,ofxhome,ofxhome.com
Platform: UNKNOWN
diff --git a/ofxhome.egg-info/SOURCES.txt b/ofxhome.egg-info/SOURCES.txt
index 2c69c46..c3daabd 100644
--- a/ofxhome.egg-info/SOURCES.txt
+++ b/ofxhome.egg-info/SOURCES.txt
@@ -7,4 +7,6 @@ ofxhome.egg-info/SOURCES.txt
ofxhome.egg-info/dependency_links.txt
ofxhome.egg-info/entry_points.txt
ofxhome.egg-info/top_level.txt
-ofxhome.egg-info/zip-safe \ No newline at end of file
+ofxhome.egg-info/zip-safe
+ofxhome/tests/__init__.py
+ofxhome/tests/test_suite.py \ No newline at end of file
diff --git a/ofxhome/__init__.py b/ofxhome/__init__.py
index 6ca3aeb..c18a369 100644
--- a/ofxhome/__init__.py
+++ b/ofxhome/__init__.py
@@ -2,7 +2,7 @@ import urllib
from datetime import datetime
from xml.dom.minidom import parseString
-__version__ = '0.3.1'
+__version__ = '0.3.2'
API_URL='http://www.ofxhome.com/api.php'
@@ -61,7 +61,10 @@ def _attr(node,name):
def _text(parent,name):
rc = []
- for node in parent.getElementsByTagName(name)[0].childNodes:
+ elements = parent.getElementsByTagName(name)
+ if not elements:
+ return ''
+ for node in elements[0].childNodes:
if node.nodeType == node.TEXT_NODE:
rc.append(node.data)
return ''.join(rc)
diff --git a/ofxhome/tests/__init__.py b/ofxhome/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ofxhome/tests/__init__.py
diff --git a/ofxhome/tests/test_suite.py b/ofxhome/tests/test_suite.py
new file mode 100644
index 0000000..92f0b98
--- /dev/null
+++ b/ofxhome/tests/test_suite.py
@@ -0,0 +1,109 @@
+import sys, os, os.path
+from ofxhome import OFXHome, Institution, InstitutionList
+import unittest
+import datetime
+
+class InstitutionTestCase(unittest.TestCase):
+
+ def testGoodParse(self):
+ xml = testfile('scottrade.xml').read()
+ i = Institution(xml)
+ self.assertEquals(i.id,'623')
+ self.assertEquals(i.name,'Scottrade, Inc.')
+ self.assertEquals(i.fid,'777')
+ self.assertEquals(i.org,'Scottrade')
+ self.assertEquals(i.brokerid,'www.scottrade.com')
+ self.assertEquals(i.url,'https://ofxstl.scottsave.com')
+ self.assertEquals(i.ofxfail,'0')
+ self.assertEquals(i.sslfail,'4')
+ self.assertEquals(i.lastofxvalidation,datetime.datetime(2012,8,13,22,28,10))
+ self.assertEquals(i.lastsslvalidation,datetime.datetime(2011,9,28,22,22,22))
+ self.assertEquals(i.xml, xml)
+
+ def testOptionalBroker(self):
+ xml = testfile('jpmorgan.xml').read()
+ i = Institution(xml)
+ self.assertEquals(i.id,'435')
+ self.assertEquals(i.name,'JPMorgan Chase Bank')
+ self.assertEquals(i.fid,'1601')
+ self.assertEquals(i.org,'Chase Bank')
+ self.assertEquals(i.brokerid,'')
+ self.assertEquals(i.url,'https://www.oasis.cfree.com/1601.ofxgp')
+ self.assertEquals(i.ofxfail,'0')
+ self.assertEquals(i.sslfail,'0')
+ self.assertEquals(i.lastofxvalidation,datetime.datetime(2014,8,17,22,23,35))
+ self.assertEquals(i.lastsslvalidation,datetime.datetime(2014,8,17,22,23,34))
+ self.assertEquals(i.xml, xml)
+
+ def testFromFile(self):
+ i = Institution.from_file( testfile_name('scottrade.xml') )
+ self.assertEquals(i.id,'623')
+ self.assertEquals(i['id'],'623')
+
+ def testDictKeys(self):
+ xml = testfile('scottrade.xml').read()
+ i = Institution(xml)
+ self.assertEquals(i['id'],'623')
+ self.assertEquals(i['name'],'Scottrade, Inc.')
+
+ i['id'] = '123'
+ self.assertEquals(i['id'],'123')
+
+ def testBadParse(self):
+ xml = testfile('badxml_bank.xml').read()
+ try:
+ l = Institution(xml)
+ self.assertFalse(0)
+ except Exception:
+ self.assertTrue(1)
+
+class InstitutionListTestCase(unittest.TestCase):
+
+ def testFromFile(self):
+ l = InstitutionList.from_file( testfile_name('search_america.xml') )
+ self.assertEquals(len(l),15)
+
+ def testGoodResult(self):
+ xml = testfile('search_america.xml').read()
+ l = InstitutionList(xml)
+ self.assertEquals(len(l),15)
+ self.assertEquals(l.xml,xml)
+ self.assertEquals(l[0]['id'],'533')
+ self.assertEquals(l[0]['name'],'America First Credit Union')
+
+ def testResultWithPHPError(self):
+ xml = testfile('search_noexist.xml').read()
+ l = InstitutionList(xml)
+ self.assertEquals(len(l),0)
+ self.assertEquals(l.xml,xml)
+
+ def testIterator(self):
+ count = 0
+ xml = testfile('search_america.xml').read()
+ l = InstitutionList(xml)
+ for i in l:
+ count += 1
+ self.assertEquals(count,15)
+
+ def testBadXML(self):
+ xml = testfile('badxml_search.xml').read()
+ try:
+ l = InstitutionList(xml)
+ self.assertFalse(0)
+ except Exception:
+ self.assertTrue(1)
+
+def testfile_name(filename):
+ base_path = os.path.dirname(os.path.abspath(__file__))
+
+ path = os.path.join(base_path,'testfiles',filename)
+ if ('tests' in os.listdir('.')):
+ path = os.path.join('tests',path)
+ return path
+
+def testfile(filename):
+ return file(testfile_name(filename))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/setup.py b/setup.py
index 0bdc1dc..ec8b736 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
setup(name='ofxhome',
- version="0.3.1",
+ version="0.3.2",
description="ofxhome.com financial institution lookup REST client",
long_description=open("./README", "r").read(),
classifiers=[
@@ -19,11 +19,11 @@ setup(name='ofxhome',
author_email='captindave@gmail.com',
url='https://github.com/captin411/ofxhome',
license='MIT License',
- packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+ packages=find_packages(exclude=['ez_setup', 'examples']),
include_package_data=True,
zip_safe=True,
install_requires=[ ],
- test_suite = 'tests',
+ test_suite = 'ofxhome.tests',
entry_points="""
""",
)