File: account.py

package info (click to toggle)
python-ofxclient 1.3.8-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 224 kB
  • ctags: 156
  • sloc: python: 1,082; makefile: 4
file content (83 lines) | stat: -rw-r--r-- 2,662 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import unittest
from ofxclient import Account
from ofxclient import BankAccount
from ofxclient import BrokerageAccount
from ofxclient import CreditCardAccount
from ofxclient import Institution

class OfxAccountTests(unittest.TestCase):

    def setUp(self):
        institution = Institution(
                id  = '1',
                org = 'Example',
                url = 'http://example.com',
                username = 'username',
                password = 'password'
        )
        self.institution = institution

    def testNumberRequired(self):
        a = { 'institution': self.institution }
        self.assertRaises(TypeError,Account,**a)

    def testInstitutionRequired(self):
        a = { 'number': '12345' }
        self.assertRaises(TypeError,Account,**a)

    def testMasked(self):
        account = Account(
                number = '12345',
                institution = self.institution
        )
        self.assertEqual( account.number_masked(), '***2345' )
        account.number = '1234'
        self.assertEqual( account.number_masked(), '***1234' )
        account.number = '123'
        self.assertEqual( account.number_masked(), '***123' )
        account.number = '12'
        self.assertEqual( account.number_masked(), '***12' )
        account.number = '1'
        self.assertEqual( account.number_masked(), '***1' )

    def testDescription(self):
        account = Account(
                number = '12345',
                institution = self.institution
        )
        self.assertEqual( account.description, '***2345', 'kwarg is not required and defaults' )

        account = Account(
                number = '12345',
                institution = self.institution,
                description = None
        )
        self.assertEqual( account.description, '***2345', 'None defaults' )

        account = Account(
                number = '12345',
                institution = self.institution,
                description = ''
        )
        self.assertEqual( account.description, '***2345', 'empty string desc defaults')

        account = Account(
                number = '12345',
                institution = self.institution,
                description = '0'
        )
        self.assertEqual( account.description, '0', '0 string is preserved')

        account = Account(
                number = '12345',
                institution = self.institution,
                description = 'passed'
        )
        self.assertEqual( account.description, 'passed' )

    def testNoInstitution(self):
        account = Account(
                number = '12345',
                institution = None
        )