Skip to content

Commit

Permalink
add test for creation of accounts with children
Browse files Browse the repository at this point in the history
  • Loading branch information
sdementen committed Dec 14, 2017
1 parent c89a065 commit 9d05171
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from piecash import Account, Commodity
from test_helper import db_sqlite_uri, db_sqlite, new_book, new_book_USD, book_uri


# dummy line to avoid removing unused symbols

a = db_sqlite_uri, db_sqlite, new_book, new_book_USD, book_uri
Expand Down Expand Up @@ -38,7 +37,6 @@ def test_create_parentless_account(self, new_book):
root_accs = new_book.query(Account).all()
assert len(root_accs) == 3


def test_create_samenameandparent_accounts(self, new_book):
EUR = new_book.commodities[0]
racc = new_book.root_account
Expand Down Expand Up @@ -100,9 +98,19 @@ def test_create_nobook_account(self, new_book):

# create account with no book attachable to it
with pytest.raises(ValueError):
acc = Account(name="test account", type="FOO", commodity=USD)
acc = Account(name="test account", type="ASSET", commodity=USD)
new_book.flush()

def test_create_children_accounts(self, new_book):
EUR = new_book.commodities[0]
racc = new_book.root_account

# create account with unknown type
acc = Account(name="test account", type="ASSET", commodity=EUR, parent=racc,
children=[Account(name="test sub-account", type="ASSET", commodity=EUR)])
new_book.flush()
assert len(acc.children) == 1

def test_create_unicodename_account(self, new_book):
EUR = new_book.commodities[0]
racc = new_book.root_account
Expand All @@ -113,7 +121,6 @@ def test_create_unicodename_account(self, new_book):
assert len(new_book.accounts) == 1
assert len(repr(acc)) >= 2


def test_create_root_subaccount(self, new_book):
EUR = new_book.commodities[0]
racc = new_book.root_account
Expand Down Expand Up @@ -148,4 +155,4 @@ def test_scu(self, new_book):
assert acc.non_std_scu
acc.commodity_scu = None
assert acc.commodity_scu == EUR.fraction
assert not acc.non_std_scu
assert not acc.non_std_scu

0 comments on commit 9d05171

Please sign in to comment.