def test_book_trading_accounts(self, new_book): assert len(new_book.accounts) == 0 assert len(new_book.currencies) == 1 # get (and create on the fly) the trading account for the default currency ncur = new_book.currencies(mnemonic="USD") cur = new_book.default_currency ta = new_book.trading_account(ncur) new_book.flush() assert len(new_book.currencies) == 2 assert len(new_book.accounts) == 3 acc = new_book.root_account.children[0] assert acc.name == "Trading" assert acc.commodity == cur acc = acc.children[0] assert acc.name == cur.namespace assert acc.commodity == cur acc = acc.children[0] assert acc.name == ncur.mnemonic assert acc.commodity == ncur ncur = new_book.currencies(mnemonic="CAD") ta = new_book.trading_account(ncur) new_book.flush() assert len(new_book.accounts) == 4 assert len(new_book.currencies) == 3 ncur = new_book.currencies(mnemonic="USD") ta = new_book.trading_account(ncur) assert len(new_book.accounts) == 4 assert len(new_book.currencies) == 3
def test_book_trading_accounts(self, new_book): assert len(new_book.accounts) == 0 assert len(new_book.currencies) == 1 # get (and create on the fly) the trading account for the default currency ncur = new_book.currencies(mnemonic="USD") cur = new_book.default_currency ta = new_book.trading_account(ncur) new_book.flush() assert len(new_book.currencies) == 2 assert len(new_book.accounts) == 3 acc = new_book.root_account.children[0] assert acc.name == "Trading" assert acc.commodity == cur acc = acc.children[0] assert acc.name == cur.namespace assert acc.commodity == cur acc = acc.children[0] assert acc.name == ncur.mnemonic assert acc.commodity == ncur ncur = new_book.currencies(mnemonic="CAD") ta = new_book.trading_account(ncur) new_book.flush() assert len(new_book.accounts) == 4 assert len(new_book.currencies) == 3 ncur = new_book.currencies(mnemonic="USD") ta = new_book.trading_account(ncur) assert len(new_book.accounts) == 4 assert len(new_book.currencies) == 3