def test_book_balance_is_sum_of_account_balances(): book = Book(code=uuid.uuid4().hex, name="New Book") account_1 = Account(name="Test Account 1", initial_balance=10) account_2 = Account(name="Test Account 2", initial_balance=20) book.register(account_1) book.register(account_2) assert book.balance == account_1.balance + account_2.balance
def test_can_add_book_with_with_mapping(session): book = Book(code=uuid.uuid4().hex, name="New Book") account = Account(name="Test Account") book.register(account) session.add(book) session.commit() account = session.query(Account).one() assert account.book == book
def test_can_register_account_in_book_only_once(account): book = Book(code=uuid.uuid4().hex, name="New Book") book.register(account) book.register(account) assert len(book.accounts) == 1
def test_can_register_account_in_book(account): book = Book(code=uuid.uuid4().hex, name="New Book") book.register(account) assert account in book.accounts