GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test_split.py
1 from unittest import main
2 
3 from gnucash import Book, Account, Split, Transaction
4 from unittest_support import *
5 
6 from test_book import BookSession
7 
9  def setUp(self):
10 
11  BookSession.setUp(self)
12  self.split = Split(self.book)
13 
14  def tearDown(self):
15  pass
16 
17 class TestSplit( SplitSession ):
18  def test_memo(self):
19  MEMO = "cookie monster"
20  self.assertEquals( '', self.split.GetMemo() )
21  self.split.SetMemo(MEMO)
22  self.assertEquals( MEMO, self.split.GetMemo() )
23 
24  def test_account(self):
25  ACCT = Account(self.book)
26  ACCT.SetCommodity(self.currency)
27  self.split.SetAccount(ACCT)
28  self.assertTrue( ACCT.Equal(self.split.GetAccount(), True) )
29 
30  def test_transaction(self):
31  domain1 = "gnc.engine.scrub"
32  msg1 = "[xaccScrubUtilityGetOrMakeAccount()] No currency specified!"
33  level = G_LOG_LEVEL_CRITICAL
34  check1 = TestErrorStruct()
35  check1.log_domain = domain1
36  check1.log_level = level
37  check1.msg = msg1
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
42  check2 = TestErrorStruct()
43  check2.log_domain = domain2
44  check2.log_level = level
45  check2.msg = msg2
46  hdlr2 = test_set_checked_handler(domain2, level, check2)
47 
48  TRANS = Transaction(self.book)
49  self.split.SetParent(TRANS)
50  TRANS.SetCurrency(self.currency)
51  TRANS.SetDescription("Foo")
52  self.assertEquals( TRANS.GetDescription(), self.split.GetParent().GetDescription() )
53 
54  g_log_remove_handler(domain2, hdlr2)
55  g_log_remove_handler(domain1, hdlr1)
56 
57  def test_equal(self):
58  COPY = self.split
59  self.assertTrue( self.split.Equal(COPY, True, False, False) )
60 
61 if __name__ == '__main__':
62  main()
struct account_s Account
Account in Gnucash. This is the typename for an account. The actual structure is defined in the priva...
Definition: gnc-engine.h:132
struct split_s Split
Split in Gnucash. A "split" is more commonly referred to as a "entry" in a "transaction". Each split belongs to one Account and one Transaction. The split is one out of several parts a Transaction is divided into.
Definition: gnc-engine.h:144
struct transaction_s Transaction
Transaction in Gnucash. A Transaction is a piece of business done; the transfer of money from one acc...
Definition: gnc-engine.h:155