Skip to content

Commit

Permalink
fig getQifName -> takes datetime.datetime, not str
Browse files Browse the repository at this point in the history
  • Loading branch information
tomquirk committed Sep 17, 2017
1 parent a717e21 commit 5518225
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
logged_in_urls = ['https://ib.nab.com.au/nabib/acctInfo_acctBal.ctl',
'https://ib.nab.com.au/nabib/loginProcess.ctl']
TRANSACTIONS_PER_PAGE = 200


def get_accounts(text):
Expand Down Expand Up @@ -234,7 +235,7 @@ def get_servers_today_date(b):


def query_server_transactions(b, start_date):
TRANSACTIONS_PER_PAGE = 200

end_date = get_servers_today_date(b)
b.select_form(name='transactionHistoryForm')
b.form['periodModeSelect'] = ['Custom']
Expand All @@ -258,7 +259,6 @@ def query_server_transactions(b, start_date):


def get_all_transactions(b, account, start_date):
TRANSACTIONS_PER_PAGE = 200
b = query_server_transactions(b, start_date)
if not b:
return None
Expand Down
16 changes: 7 additions & 9 deletions lib/qif.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

import re
import os
import time
import datetime


def get_qif_name(start_date, end_date):

date_format = '%Y.%m.%d'
start = time.strptime(start_date, "%d %b %y")
end = time.strptime(end_date, "%d %b %y")

return '%d.%d.%d - %d.%d.%d.qif' % (
start[0], start[1], start[2],
end[0], end[1], end[2],
"""
Takes 2 datetime.datetime objects and returns a string representing the QIF file name
"""
return '20%s - 20%s.qif' % (
datetime.datetime.strftime(start_date, "%y.%m.%d"),
datetime.datetime.strftime(end_date, "%y.%m.%d"),
)


Expand Down
8 changes: 6 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest

from lib import qif
import datetime


class TestQIF(unittest.TestCase):
Expand All @@ -12,8 +13,11 @@ def setUp(self):

def test_get_qif_name(self):

name = qif.get_qif_name('1 Jan 10', '13 Apr 12')
self.assertEqual(name, '2010.1.1 - 2012.4.13.qif')
name = qif.get_qif_name(
datetime.datetime(2010, 1, 1, 00, 00, 00),
datetime.datetime(2012, 4, 13, 00, 00, 00)
)
self.assertEqual(name, '2010.01.01 - 2012.04.13.qif')

def test_is_file_present(self):

Expand Down

0 comments on commit 5518225

Please sign in to comment.