Skip to content

Commit

Permalink
issue #104 - test statement dates
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Aug 19, 2017
1 parent d2dbda1 commit 38e40de
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions biweeklybudget/tests/unit/test_interest.py
Expand Up @@ -41,6 +41,7 @@
import pytest
from math import ceil
from decimal import Decimal
from copy import deepcopy

from biweeklybudget.interest import (
InterestHelper,
Expand Down Expand Up @@ -1965,28 +1966,28 @@ def test_calculate(self, data):
icls = AdbCompoundedDaily(data['apr'])
mpc = MinPaymentAmEx()
bp = _BillingPeriod(data['end'])
bp._end_date = data['end']
bp._start_date = data['start']
bp._end_date = deepcopy(data['end'])
bp._start_date = deepcopy(data['start'])
res = CCStatement(
icls,
data['start_bal'],
mpc,
bp,
transactions=data['transactions']
)
assert res.start_date == data['start']
assert res.end_date == data['end']
assert pctdiff(
round(res.principal, 2), data['end_balance']) < Decimal('0.01')
assert pctdiff(
round(res.interest, 2), data['interest_amt']) < Decimal('0.01')
assert res.start_date == data['start']
assert res.end_date == data['end']

def test_calculate_min_payment(self, data):
icls = AdbCompoundedDaily(data['apr'])
mpc = MinPaymentAmEx()
bp = _BillingPeriod(data['end'])
bp._end_date = data['end']
bp._start_date = data['start']
bp._end_date = deepcopy(data['end'])
bp._start_date = deepcopy(data['start'])
res = CCStatement(
icls,
data['start_bal'],
Expand All @@ -1996,14 +1997,16 @@ def test_calculate_min_payment(self, data):
end_balance=data['end_balance'],
interest_amt=data['interest_amt']
)
assert res.start_date == data['start']
assert res.end_date == data['end']
assert int(res.minimum_payment) == data['payoffs'][0][0]

def test_calculate_payoff_min(self, data):
icls = AdbCompoundedDaily(data['apr'])
mpc = MinPaymentAmEx()
bp = _BillingPeriod(data['end'])
bp._end_date = data['end']
bp._start_date = data['start']
bp._end_date = deepcopy(data['end'])
bp._start_date = deepcopy(data['start'])
stmt = CCStatement(
icls,
data['start_bal'],
Expand All @@ -2017,15 +2020,17 @@ def test_calculate_payoff_min(self, data):
MinPaymentMethod(),
[stmt]
)
assert stmt.start_date == data['start']
assert stmt.end_date == data['end']
assert int(round(res[0][0]/12)) == data['payoffs'][0][1]
assert pctdiff(res[0][1], data['payoffs'][0][2]) < Decimal('0.01')

def test_calculate_payoff_recommended(self, data):
icls = AdbCompoundedDaily(data['apr'])
mpc = MinPaymentAmEx()
bp = _BillingPeriod(data['end'])
bp._end_date = data['end']
bp._start_date = data['start']
bp._end_date = deepcopy(data['end'])
bp._start_date = deepcopy(data['start'])
stmt = CCStatement(
icls,
data['start_bal'],
Expand All @@ -2039,6 +2044,8 @@ def test_calculate_payoff_recommended(self, data):
FixedPaymentMethod(data['payoffs'][1][0]),
[stmt]
)
assert stmt.start_date == data['start']
assert stmt.end_date == data['end']
assert int(round(res[0][0]/12)) == data['payoffs'][1][1]
assert pctdiff(res[0][1], data['payoffs'][1][2]) < Decimal('0.01')

Expand Down

0 comments on commit 38e40de

Please sign in to comment.