def test_2_confirm_pp(self, testdb):
     acct_bal = NotificationsController.budget_account_sum(testdb)
     assert acct_bal == Decimal('428990.47')
     stand_bal = NotificationsController.standing_budgets_sum(testdb)
     assert stand_bal == Decimal('10766.52')
     pp_bal = NotificationsController.pp_sum(testdb)
     assert pp_bal == Decimal('11.76')
     unrec_amt = NotificationsController.budget_account_unreconciled(testdb)
     assert unrec_amt == Decimal('-333.33')
 def test_1_confirm_pp(self, testdb):
     acct_bal = NotificationsController.budget_account_sum(testdb)
     assert acct_bal == Decimal('12889.24')
     stand_bal = NotificationsController.standing_budgets_sum(testdb)
     assert stand_bal == Decimal('11099.85')
     pp_bal = NotificationsController.pp_sum(testdb)
     assert pp_bal == Decimal('11.76')
     unrec_amt = NotificationsController.budget_account_unreconciled(testdb)
     assert unrec_amt == Decimal('33666.67')
 def test_1_confirm_pp(self, testdb):
     acct_bal = NotificationsController.budget_account_sum(testdb)
     assert acct_bal == 12889.24
     stand_bal = NotificationsController.standing_budgets_sum(testdb)
     assert stand_bal == 11099.85
     pp_bal = NotificationsController.pp_sum(testdb)
     # floating point awfulness
     assert "%.2f" % pp_bal == '11.76'
     unrec_amt = NotificationsController.budget_account_unreconciled(testdb)
     assert unrec_amt == 33666.67
 def test_get_notifications_one_stale(self):
     with patch.multiple(pb,
                         num_stale_accounts=DEFAULT,
                         budget_account_sum=DEFAULT,
                         standing_budgets_sum=DEFAULT,
                         num_unreconciled_ofx=DEFAULT,
                         budget_account_unreconciled=DEFAULT,
                         pp_sum=DEFAULT) as mocks:
         mocks['num_stale_accounts'].return_value = 1
         mocks['budget_account_sum'].return_value = 1000
         mocks['standing_budgets_sum'].return_value = 1
         mocks['num_unreconciled_ofx'].return_value = 28
         mocks['budget_account_unreconciled'].return_value = 0
         mocks['pp_sum'].return_value = 0
         res = NotificationsController.get_notifications()
     assert res == [{
         'classes':
         'alert alert-danger',
         'content':
         '1 Account with stale data. <a href="/accounts" '
         'class="alert-link">View Accounts</a>.'
     }, {
         'classes':
         'alert alert-warning unreconciled-alert',
         'content':
         '28 <a href="/reconcile" class="alert-link">'
         'Unreconciled OFXTransactions</a>.'
     }]
Exemple #5
0
 def test_get_notifications_over_balance(self):
     with patch.multiple(
             pb,
             num_stale_accounts=DEFAULT,
             budget_account_sum=DEFAULT,
             standing_budgets_sum=DEFAULT,
             num_unreconciled_ofx=DEFAULT,
             budget_account_unreconciled=DEFAULT,
             pp_sum=DEFAULT
     ) as mocks:
         mocks['num_stale_accounts'].return_value = 0
         mocks['budget_account_sum'].return_value = 1000
         mocks['standing_budgets_sum'].return_value = 500
         mocks['num_unreconciled_ofx'].return_value = 0
         mocks['budget_account_unreconciled'].return_value = 700
         mocks['pp_sum'].return_value = 600
         res = NotificationsController.get_notifications()
     assert res == [
         {
             'classes': 'alert alert-danger',
             'content': 'Combined balance of all <a href="/accounts">'
                        'budget-funding accounts</a> '
                        '(%s) is less than all allocated funds total of '
                        '%s (%s <a href="/budgets">standing budgets</a>; '
                        '%s <a href="/pay_period_for">current pay '
                        'period remaining</a>; %s <a href="/reconcile">'
                        'unreconciled</a>)!' % (
                            '$1,000.00', '$1,800.00', '$500.00',
                            '$600.00', '$700.00'
                        )
         }
     ]
def notifications():
    """
    Add notifications to template context for all templates.

    :return: template context with notifications added
    :rtype: dict
    """
    return dict(notifications=NotificationsController().get_notifications())
 def test_num_stale_accounts(self):
     accts = [
         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.filter.return_value\
             .all.return_value = accts
         res = NotificationsController.num_stale_accounts()
     assert res == 1
     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.multiple(pb,
                         num_stale_accounts=DEFAULT,
                         budget_account_sum=DEFAULT,
                         standing_budgets_sum=DEFAULT,
                         num_unreconciled_ofx=DEFAULT,
                         budget_account_unreconciled=DEFAULT,
                         pp_sum=DEFAULT) as mocks:
         mocks['num_stale_accounts'].return_value = 0
         mocks['budget_account_sum'].return_value = 1000
         mocks['standing_budgets_sum'].return_value = 1
         mocks['num_unreconciled_ofx'].return_value = 0
         mocks['budget_account_unreconciled'].return_value = 0
         mocks['pp_sum'].return_value = 0
         res = NotificationsController.get_notifications()
     assert res == []