Example #1
0
def test_info_uses_today(transactions_json):
    client = FioBank('...')
    today = date.today()

    options = {'return_value': transactions_json}
    with mock.patch.object(client, '_request', **options) as stub:
        client.info()
        stub.assert_called_once_with('periods', from_date=today, to_date=today)
Example #2
0
def test_info_uses_today(transactions_json):
    client = FioBank('...')
    today = date.today()

    options = {'return_value': transactions_json}
    with mock.patch.object(client, '_request', **options) as stub:
        client.info()
        stub.assert_called_once_with('periods', from_date=today, to_date=today)
from decimal import Decimal

from time import sleep
import datetime
import logging

#FIRST_DATE = datetime.date(2010, 9, 1)
FIRST_DATE = datetime.date(2015,1,1)
logger = logging.getLogger(__name__)



for token in settings.BANK_TOKENS:
    client = FioBank(token=token)
    info = client.info()
    curr,created = Currency.objects.get_or_create(symbol=info.get('currency'))
    if created:
        curr.name = curr.symbol
        curr.save()
    my,created = BankAccount.objects.get_or_create(account_number=info['account_number'], bank_code=info['bank_code'])
    if created:
        my.currency = curr
        my.save()
    logger.info('Processing account %s...' % my)
    try:
        from_id = BankTransaction.objects.filter(my_account=my).latest('date').tid
        sleep(30) # to avoid HTTP 409 - "Conflict" response
        trans = client.last(from_id=from_id)
    except ObjectDoesNotExist:
        sleep(30) # to avoid HTTP 409 - "Conflict" response