Files
@ 0d370c445b9e
Branch filter:
Location: NPO-Accounting/conservancy_beancount/tests/test_data_account.py - annotation
0d370c445b9e
2.8 KiB
text/x-python
plugin: User configuration is passed to hooks on initialization.
6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 7bc0ded9c6cb 6c0f23b2fa2f 6c0f23b2fa2f 6c0f23b2fa2f 9b8563f3f03b 9b8563f3f03b 6c0f23b2fa2f 28238643a398 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 9b8563f3f03b 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 7cd569be7b52 28238643a398 28238643a398 28238643a398 28238643a398 28238643a398 28238643a398 89aaae821b30 28238643a398 28238643a398 28238643a398 28238643a398 28238643a398 28238643a398 | """Test Account class"""
# Copyright © 2020 Brett Smith
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import pytest
from conservancy_beancount import data
@pytest.mark.parametrize('acct_name,under_arg,expected', [
('Expenses:Tax:Sales', 'Expenses:Tax:Sales:', False),
('Expenses:Tax:Sales', 'Expenses:Tax:Sales', True),
('Expenses:Tax:Sales', 'Expenses:Tax:', True),
('Expenses:Tax:Sales', 'Expenses:Tax', True),
('Expenses:Tax:Sales', 'Expenses:', True),
('Expenses:Tax:Sales', 'Expenses', True),
('Expenses:Tax:Sales', 'Expense', False),
('Expenses:Tax:Sales', 'Accrued:', False),
('Expenses:Tax:Sales', 'Accrued', False),
])
def test_is_under_one_arg(acct_name, under_arg, expected):
expected = under_arg if expected else None
assert data.Account(acct_name).is_under(under_arg) == expected
@pytest.mark.parametrize('acct_name,expected', [
('Income:Other', 'Income'),
('UnearnedIncome:Other', 'UnearnedIncome'),
('Accrued:AccountsPayable', None),
('Expenses:General', None),
])
def test_is_under_multi_arg(acct_name, expected):
assert data.Account(acct_name).is_under('Income', 'UnearnedIncome') == expected
if expected:
expected += ':'
assert data.Account(acct_name).is_under('Income:', 'UnearnedIncome:') == expected
@pytest.mark.parametrize('acct_name,expected', [
('Accrued:AccountsReceivable', False),
('Assets:Cash', False),
('Expenses:General', False),
('Income:Donations', True),
('Income:Sales', True),
('Income:Other', True),
('Liabilities:CreditCard', False),
('UnearnedIncome:MatchPledges', True),
])
def test_is_income(acct_name, expected):
assert data.Account(acct_name).is_income() == expected
@pytest.mark.parametrize('acct_name,expected', [
('Accrued:AccountsPayable', False),
('Accrued:AccountsReceivable', False),
('Assets:Cash', True),
('Assets:Cash:EUR', True),
('Assets:PrepaidExpenses', False),
('Assets:PrepaidVacation', False),
('Assets:Bank:Checking', True),
('Expenses:General', False),
('Income:Donations', False),
])
def test_is_real_asset(acct_name, expected):
assert data.Account(acct_name).is_real_asset() == expected
|