1 from unittest
import main
3 from gnucash
import Book, Account, Split, Transaction
4 from unittest_support
import *
6 from test_book
import BookSession
11 BookSession.setUp(self)
17 class TestSplit(SplitSession):
19 MEMO =
"cookie monster" 20 self.assertEqual(
'', self.split.GetMemo() )
21 self.split.SetMemo(MEMO)
22 self.assertEqual( MEMO, self.split.GetMemo() )
25 ACCT = Account(self.book)
26 ACCT.SetCommodity(self.currency)
27 self.split.SetAccount(ACCT)
28 self.assertTrue( ACCT.Equal(self.split.GetAccount(),
True) )
31 domain1 =
"gnc.engine.scrub" 32 msg1 =
"[xaccScrubUtilityGetOrMakeAccount()] No currency specified!" 33 level = G_LOG_LEVEL_CRITICAL
35 check1.log_domain = domain1
36 check1.log_level = level
38 hdlr1 = test_set_checked_handler(domain1, level, check1)
39 domain2 =
"gnc.engine" 40 msg2 =
"[xaccTransScrubSplits()] Transaction doesn't have a currency!" 41 level = G_LOG_LEVEL_CRITICAL
43 check2.log_domain = domain2
44 check2.log_level = level
46 hdlr2 = test_set_checked_handler(domain2, level, check2)
48 TRANS = Transaction(self.book)
49 self.split.SetParent(TRANS)
50 TRANS.SetCurrency(self.currency)
51 TRANS.SetDescription(
"Foo")
52 self.assertEqual( TRANS.GetDescription(), self.split.GetParent().GetDescription() )
54 g_log_remove_handler(domain2, hdlr2)
55 g_log_remove_handler(domain1, hdlr1)
59 self.assertTrue( self.split.Equal(COPY,
True,
False,
False) )
61 TRANS = Transaction(self.book)
62 self.split.SetParent(TRANS)
63 self.assertTrue( self.split == TRANS.GetSplitList()[0] )
64 self.assertTrue( self.split != Split(self.book) )
66 if __name__ ==
'__main__':
Struct to pass as user_data for the handlers.