示例#1
0
  def test_get(self):
    root_account = gcdomain_test_util.root_account(account_id='root-account')
    checking_account = gcdomain_test_util.account(account_id='checking-account')
    savings_account = gcdomain_test_util.account(account_id='savings-account')
    expense_account = gcdomain_test_util.account(account_id='expenses')

    # Buy with savings, buy with checking, transfer savings to checking
    checking_purchase = gcdomain_test_util.transaction(
        date_posted='2011-10-08 12:00:00 -0600',
        splits=[(-5, 'checking-account'), (5, 'expenses')])
    savings_purchase = gcdomain_test_util.transaction(
        date_posted='2011-10-09 12:00:00 -0600',
        splits=[(-1500, 'savings-account'), (1500, 'expenses')])
    savings_transfer = gcdomain_test_util.transaction(
        date_posted='2011-10-15 12:00:00 -0600',
        splits=[(-500, 'savings-account'), (500, 'checking-account')])

    book = Book(
        book_id='book',
        commodities=[],
        accounts=[root_account, checking_account, savings_account],
        transactions=[savings_transfer, savings_purchase, checking_purchase])

    # Transactions should be sorted by date
    self.assertEqual([checking_purchase, savings_transfer],
        book.transactions.get(account_id='checking-account'))
    self.assertEqual([savings_purchase, savings_transfer],
        book.transactions.get(account_id='savings-account'))
    self.assertEqual([checking_purchase, savings_purchase],
        book.transactions.get(account_id='expenses'))
示例#2
0
 def test_repr(self):
   transaction = gcdomain_test_util.transaction()
   self.assertEqual(transaction, eval(repr(transaction)))