GnuCash 2.4.99
test_split.py
00001 from unittest import main
00002 
00003 from gnucash import Book, Account, Split, Transaction
00004 from unittest_support import *
00005 
00006 from test_book import BookSession
00007 
00008 class SplitSession( BookSession ):
00009     def setUp(self):
00010 
00011         BookSession.setUp(self)
00012         self.split = Split(self.book)
00013 
00014     def tearDown(self):
00015         pass
00016 
00017 class TestSplit( SplitSession ):
00018     def test_memo(self):
00019         MEMO = "cookie monster"
00020         self.assertEquals( '', self.split.GetMemo() )
00021         self.split.SetMemo(MEMO)
00022         self.assertEquals( MEMO, self.split.GetMemo() )
00023 
00024     def test_account(self):
00025         ACCT = Account(self.book)
00026         ACCT.SetCommodity(self.currency)
00027         self.split.SetAccount(ACCT)
00028         self.assertTrue( ACCT.Equal(self.split.GetAccount(), True) )
00029 
00030     def test_transaction(self):
00031         domain1 = "gnc.engine.scrub"
00032         msg1 = "[xaccScrubUtilityGetOrMakeAccount()] No currency specified!"
00033         level = G_LOG_LEVEL_CRITICAL
00034         check1 = TestErrorStruct()
00035         check1.log_domain = domain1
00036         check1.log_level = level
00037         check1.msg = msg1
00038         hdlr1 = test_set_checked_handler(domain1, level, check1)
00039         domain2 = "gnc.engine"
00040         msg2 = "[xaccTransScrubSplits()] Transaction doesn't have a currency!"
00041         level = G_LOG_LEVEL_CRITICAL
00042         check2 = TestErrorStruct()
00043         check2.log_domain = domain2
00044         check2.log_level = level
00045         check2.msg = msg2
00046         hdlr2 = test_set_checked_handler(domain2, level, check2)
00047 
00048         TRANS = Transaction(self.book)
00049         self.split.SetParent(TRANS)
00050         TRANS.SetCurrency(self.currency)
00051         TRANS.SetDescription("Foo")
00052         self.assertEquals( TRANS.GetDescription(), self.split.GetParent().GetDescription() )
00053 
00054         g_log_remove_handler(domain2, hdlr2)
00055         g_log_remove_handler(domain1, hdlr1)
00056 
00057     def test_equal(self):
00058         COPY = self.split
00059         self.assertTrue( self.split.Equal(COPY, True, False, False) )
00060 
00061 if __name__ == '__main__':
00062     main()
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines