GnuCash c935c2f+
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
test_transaction.TestTransaction Class Reference
Inheritance diagram for test_transaction.TestTransaction:
test_transaction.TransactionSession test_book.BookSession

Public Member Functions

 test_equal (self)
 
 test_clone (self)
 
 test_setcurrency (self)
 
 test_edit (self)
 
 test_rollback (self)
 
 test_findsplit (self)
 
 test_getsplit (self)
 
 test_getsplitindex (self)
 
 test_countsplits (self)
 
 test_readonly (self)
 
 test_num (self)
 
 test_description (self)
 
 test_notes (self)
 
 test_date (self)
 
- Public Member Functions inherited from test_transaction.TransactionSession
 setUp (self)
 
 tearDown (self)
 

Data Fields

 trans
 
 currency
 
 split
 
- Data Fields inherited from test_transaction.TransactionSession
 domain1
 
 domain2
 
 hdlr1
 
 hdlr2
 
 trans
 
 split
 
 currency
 
- Data Fields inherited from test_book.BookSession
 ses
 
 book
 
 table
 
 currency
 

Detailed Description

Definition at line 44 of file test_transaction.py.

Member Function Documentation

◆ test_clone()

test_transaction.TestTransaction.test_clone (   self)

Definition at line 54 of file test_transaction.py.

54 def test_clone(self):
55 domain = "gnc.engine"
56 level = G_LOG_LEVEL_WARNING
57 check = TestErrorStruct()
58 check.log_domain = domain
59 check.log_level = level
60 check.msg = "[xaccTransEqual()] GUIDs differ"
61 hdlr = test_set_checked_handler(domain, level, check)
62
63 TRANS = self.trans.Clone()
64 #Clone and original should have different GUIDs
65 self.assertFalse( TRANS.Equal(self.trans, True, False, False, False) )
66 #Clone and original should have the same balance
67 self.assertTrue( TRANS.Equal(self.trans, False, False, True, False) )
68
69 g_log_remove_handler(domain, hdlr)
70
Struct to pass as user_data for the handlers.

◆ test_countsplits()

test_transaction.TestTransaction.test_countsplits (   self)

Definition at line 104 of file test_transaction.py.

104 def test_countsplits(self):
105 self.assertEqual( 1, self.trans.CountSplits() )
106

◆ test_date()

test_transaction.TestTransaction.test_date (   self)

Definition at line 133 of file test_transaction.py.

133 def test_date(self):
134 ZERODATE=datetime(1970, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
135 DATE=datetime(2020, 2, 20, 10, 59, 0, tzinfo=timezone.utc)
136 self.assertEqual(ZERODATE, self.trans.GetDate().astimezone(timezone.utc))
137 self.trans.SetDate(DATE.day, DATE.month, DATE.year)
138 self.assertEqual(DATE, self.trans.GetDate().astimezone(timezone.utc))
139

◆ test_description()

test_transaction.TestTransaction.test_description (   self)

Definition at line 121 of file test_transaction.py.

121 def test_description(self):
122 DESCR = 'Groceries'
123 self.assertEqual( '', self.trans.GetDescription() )
124 self.trans.SetDescription(DESCR)
125 self.assertEqual( DESCR, self.trans.GetDescription() )
126

◆ test_edit()

test_transaction.TestTransaction.test_edit (   self)

Definition at line 74 of file test_transaction.py.

74 def test_edit(self):
75 self.assertFalse( self.trans.IsOpen() )
76 self.trans.BeginEdit()
77 self.assertTrue( self.trans.IsOpen() )
78 self.trans.CommitEdit()
79 self.assertFalse( self.trans.IsOpen() )
80

◆ test_equal()

test_transaction.TestTransaction.test_equal (   self)

Definition at line 45 of file test_transaction.py.

45 def test_equal(self):
46 TRANS = self.trans
47 self.assertTrue( TRANS.Equal(self.trans, True, False, False, False) )
48 # test __eq__ implementation
49 SPLIT = Split(self.book)
50 SPLIT.SetParent(TRANS)
51 self.assertTrue( self.trans == SPLIT.GetParent() )
52 self.assertTrue( self.trans != Transaction(self.book) )
53

◆ test_findsplit()

test_transaction.TestTransaction.test_findsplit (   self)

Definition at line 90 of file test_transaction.py.

90 def test_findsplit(self):
91 ACCT = Account(self.book)
92 ACCT.SetCommodity(self.currency)
93 self.split.SetAccount( ACCT )
94 SPLIT = self.trans.FindSplitByAccount( ACCT )
95 self.assertTrue( SPLIT.Equal(self.split, True, False, False) )
96
STRUCTS.

◆ test_getsplit()

test_transaction.TestTransaction.test_getsplit (   self)

Definition at line 97 of file test_transaction.py.

97 def test_getsplit(self):
98 SPLIT = self.trans.GetSplit(0)
99 self.assertTrue( SPLIT.Equal(self.split, True, False, False) )
100

◆ test_getsplitindex()

test_transaction.TestTransaction.test_getsplitindex (   self)

Definition at line 101 of file test_transaction.py.

101 def test_getsplitindex(self):
102 self.assertEqual( 0, self.trans.GetSplitIndex(self.split) )
103

◆ test_notes()

test_transaction.TestTransaction.test_notes (   self)

Definition at line 127 of file test_transaction.py.

127 def test_notes(self):
128 NOTE = 'For dinner party'
129 self.assertEqual( None, self.trans.GetNotes() )
130 self.trans.SetNotes(NOTE)
131 self.assertEqual( NOTE, self.trans.GetNotes() )
132

◆ test_num()

test_transaction.TestTransaction.test_num (   self)

Definition at line 115 of file test_transaction.py.

115 def test_num(self):
116 NUM = '5'
117 self.assertEqual( '', self.trans.GetNum() )
118 self.trans.SetNum(NUM)
119 self.assertEqual( NUM, self.trans.GetNum() )
120

◆ test_readonly()

test_transaction.TestTransaction.test_readonly (   self)

Definition at line 107 of file test_transaction.py.

107 def test_readonly(self):
108 self.assertEqual( None, self.trans.GetReadOnly() )
109 REASON = 'none'
110 self.trans.SetReadOnly(REASON)
111 self.assertEqual( REASON, self.trans.GetReadOnly() )
112 self.trans.ClearReadOnly()
113 self.assertEqual( None, self.trans.GetReadOnly() )
114

◆ test_rollback()

test_transaction.TestTransaction.test_rollback (   self)

Definition at line 81 of file test_transaction.py.

81 def test_rollback(self):
82 self.assertEqual( '', self.trans.GetDescription() )
83 self.trans.BeginEdit()
84 DESC = 'Food'
85 self.trans.SetDescription(DESC)
86 self.assertEqual( DESC, self.trans.GetDescription() )
87 self.trans.RollbackEdit()
88 self.assertEqual( '', self.trans.GetDescription() )
89

◆ test_setcurrency()

test_transaction.TestTransaction.test_setcurrency (   self)

Definition at line 71 of file test_transaction.py.

71 def test_setcurrency(self):
72 self.assertTrue( self.currency.equal( self.trans.GetCurrency() ) )
73

Field Documentation

◆ currency

test_transaction.TestTransaction.currency

Definition at line 92 of file test_transaction.py.

◆ split

test_transaction.TestTransaction.split

Definition at line 95 of file test_transaction.py.

◆ trans

test_transaction.TestTransaction.trans

Definition at line 47 of file test_transaction.py.


The documentation for this class was generated from the following file: