Skip to content

Commit

Permalink
issue #104 - WIP fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Aug 20, 2017
1 parent ed0a04e commit 79afea3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions biweeklybudget/flaskapp/filters.py
Expand Up @@ -197,5 +197,5 @@ def dict_to_class_args(j):
@app.template_filter('monthsyears')
def monthsyears(num):
if num < 12:
return '%d months' % num
return '%d years' % int(round(num / 12.0))
return '%f months' % num
return '%.1f years' % (num / 12.0)
4 changes: 0 additions & 4 deletions biweeklybudget/flaskapp/templates/account.html
Expand Up @@ -44,10 +44,6 @@
<th>Interest Class</th>
<td>{{ acct.interest_class_name }}</td>
</tr>
<tr>
<th>Billing Period Class</th>
<td>{{ acct.billing_period_class_name }}({{ acct.billing_period_class_args_deserialized|dict_to_class_args }})</td>
</tr>
<tr>
<th>Minimum Payment Class</th>
<td>{{ acct.min_payment_class_name }}</td>
Expand Down
18 changes: 8 additions & 10 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_account.py
Expand Up @@ -190,20 +190,19 @@ def test_acct_table(self, selenium):
table = panel.find_element_by_tag_name('table')
texts = self.tbody2textlist(table)
elems = self.tbody2elemlist(table)
assert texts[0:8] == [
assert texts[0:7] == [
['Description', 'First Credit Card, limit 2000'],
['Type', 'Credit'],
['Ledger Balance', '-$952.06'],
['Credit Limit', '$2,000.00'],
['APR', '1.00%'],
['Interest Class', 'AdbCompoundedDaily'],
['Billing Period Class', 'BillingPeriodNumDays(30)'],
['Minimum Payment Class', 'MinPaymentAmEx']
]
assert texts[8][0] == 'Last OFX Data'
assert texts[7][0] == 'Last OFX Data'
assert '(13 hours ago)' in texts[8][1]
assert elems[8][1].get_attribute('class') == 'data_age'
assert texts[9:] == [
assert elems[7][1].get_attribute('class') == 'data_age'
assert texts[8:] == [
['Active?', 'True'],
['OFXGetter Config', 'None'],
['reconcile_trans', 'True'],
Expand Down Expand Up @@ -246,20 +245,19 @@ def test_acct_table(self, selenium):
table = panel.find_element_by_tag_name('table')
texts = self.tbody2textlist(table)
elems = self.tbody2elemlist(table)
assert texts[0:8] == [
assert texts[0:7] == [
['Description', 'Credit 2 limit 5500'],
['Type', 'Credit'],
['Ledger Balance', '-$5,498.65'],
['Credit Limit', '$5,500.00'],
['APR', '10.00%'],
['Interest Class', 'AdbCompoundedDaily'],
['Billing Period Class', 'BillingPeriodNumDays(30)'],
['Minimum Payment Class', 'MinPaymentDiscover']
]
assert texts[8][0] == 'Last OFX Data'
assert texts[7][0] == 'Last OFX Data'
assert '(a day ago)' in texts[8][1]
assert elems[8][1].get_attribute('class') == 'data_age'
assert texts[9:] == [
assert elems[7][1].get_attribute('class') == 'data_age'
assert texts[8:] == [
['Active?', 'True'],
['OFXGetter Config', ''],
['reconcile_trans', 'True'],
Expand Down
Expand Up @@ -157,9 +157,9 @@ def test_01_highest_balance_payment(self, base_url, selenium):
table = selenium.find_element_by_id('table_HighestBalanceFirstMethod')
texts = self.tbody2textlist(table)
assert texts == [
['CreditOne (3)', '2 years', '$963.21', '$11.15'],
['CreditTwo (4)', '5 years', '$6,992.95', '$1,494.30'],
['Totals', '5 years', '$7,956.17', '$1,505.46']
['CreditOne (3)', '2.3 years', '$963.08', '$10.94'],
['CreditTwo (4)', '4.6 years', '$6,957.60', '$1,494.30'],
['Totals', '4.6 years', '$7,920.61', '$1,458.95']
]

def test_02_highest_interest_payment(self, base_url, selenium):
Expand All @@ -169,19 +169,19 @@ def test_02_highest_interest_payment(self, base_url, selenium):
)
texts = self.tbody2textlist(table)
assert texts == [
['CreditOne (3)', '2 years', '$963.21', '$11.15'],
['CreditTwo (4)', '5 years', '$6,992.95', '$1,494.30'],
['Totals', '5 years', '$7,956.17', '$1,505.46']
['CreditOne (3)', '2.3 years', '$963.01', '$10.95'],
['CreditTwo (4)', '4.6 years', '$6,957.60', '$1,494.30'],
['Totals', '4.6 years', '$7,920.61', '$1,458.95']
]

def test_03_lowest_balance_payment(self, base_url, selenium):
self.get(selenium, base_url + '/accounts/credit-payoff')
table = selenium.find_element_by_id('table_LowestBalanceFirstMethod')
texts = self.tbody2textlist(table)
assert texts == [
['CreditOne (3)', '2 years', '$961.11', '$9.05'],
['CreditTwo (4)', '5 years', '$7,024.72', '$1,526.07'],
['Totals', '5 years', '$7,985.82', '$1,535.11']
['CreditOne (3)', '1.8 years', '$960.94', '$8.88'],
['CreditTwo (4)', '4.7 years', '$6,989.41', '$1,490.76'],
['Totals', '4.7 years', '$7,985.82', '$1,499.64']
]

def test_04_lowest_interest_payment(self, base_url, selenium):
Expand All @@ -191,19 +191,19 @@ def test_04_lowest_interest_payment(self, base_url, selenium):
)
texts = self.tbody2textlist(table)
assert texts == [
['CreditOne (3)', '2 years', '$961.11', '$9.05'],
['CreditTwo (4)', '5 years', '$7,024.72', '$1,526.07'],
['Totals', '5 years', '$7,985.82', '$1,535.11']
['CreditOne (3)', '1.8 years', '$960.94', '$8.88'],
['CreditTwo (4)', '4.7 years', '$6,989.41', '$1,490.76'],
['Totals', '4.7 years', '$7,985.82', '$1,499.64']
]

def test_05_min_payment(self, base_url, selenium):
self.get(selenium, base_url + '/accounts/credit-payoff')
table = selenium.find_element_by_id('table_MinPaymentMethod')
texts = self.tbody2textlist(table)
assert texts == [
['CreditOne (3)', '2 years', '$963.21', '$11.15'],
['CreditTwo (4)', '14 years', '$8,764.66', '$3,266.01'],
['Totals', '14 years', '$9,727.87', '$3,277.16']
['CreditOne (3)', '2.3 years', '$963.01', '$10.95'],
['CreditTwo (4)', '13.5 years', '$8,666.30', '$3,167.65'],
['Totals', '13.5 years', '$9,629.31', '$3,178.60']
]


Expand Down
5 changes: 5 additions & 0 deletions biweeklybudget/tests/unit/test_interest.py
Expand Up @@ -1205,6 +1205,11 @@ def test_cc_two_pay_min(self):
)
assert res == [(162, Decimal('8666.307398441498144465534193'))]

def test_cc_combined_minimum(self):
assert (
self.stmt_cc_one.minimum_payment + self.stmt_cc_two.minimum_payment
) == Decimal('144.98')

def test_combined_pay_min(self):
res = calculate_payoffs(
MinPaymentMethod(),
Expand Down

0 comments on commit 79afea3

Please sign in to comment.