Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Apr 1, 2017
1 parent eb6a68a commit 0e507ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 5 additions & 3 deletions biweeklybudget/flaskapp/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ def get_notifications():
'content': 'Combined balance of all <a href="/accounts">'
'budget-funding accounts</a> '
'(%s) is less than balance of all <a href='
'"/budgets">standing budgets</a> (%s)!' % (
dollars_filter(accounts_bal), dollars_filter(standing_bal)
)
'"/budgets">standing budgets</a> (%s)!'
'' % (
dollars_filter(accounts_bal),
dollars_filter(standing_bal)
)
})
res.append({
'classes': 'alert alert-warning',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ def test_3_verify_db(self, testdb):
assert b.is_active is True



@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestBudgetOverBalanceNotification(AcceptanceHelper):
Expand Down
13 changes: 6 additions & 7 deletions biweeklybudget/tests/unit/flaskapp/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ class TestNotifications(object):

def test_num_stale_accounts(self):
accts = [
Mock(is_stale=True),
Mock(is_stale=False),
Mock(is_stale=True, is_active=True),
Mock(is_stale=False, is_active=True)
]
with patch('%s.db_session' % pbm) as mock_db:
mock_db.query.return_value.all.return_value = accts
mock_db.query.return_value.filter.return_value\
.all.return_value = accts
res = NotificationsController.num_stale_accounts()
assert res == 1
assert mock_db.mock_calls == [
call.query(Account),
call.query().all()
]
assert mock_db.mock_calls[0] == call.query(Account)
assert mock_db.mock_calls[2] == call.query().filter().all()

def test_get_notifications_no_stale(self):
with patch('%s.num_stale_accounts' % pb) as m_num_stale:
Expand Down

0 comments on commit 0e507ef

Please sign in to comment.