diff options
-rw-r--r-- | src/py_xact.cc | 2 | ||||
-rw-r--r-- | test/python/TransactionTest.py | 27 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/py_xact.cc b/src/py_xact.cc index 3474c127..5f062294 100644 --- a/src/py_xact.cc +++ b/src/py_xact.cc @@ -100,7 +100,7 @@ void export_xact() return_internal_reference<>()) .def("add_post", &xact_base_t::add_post, with_custodian_and_ward<1, 2>()) - .def("remove_post", &xact_base_t::add_post) + .def("remove_post", &xact_base_t::remove_post) .def("finalize", &xact_base_t::finalize) diff --git a/test/python/TransactionTest.py b/test/python/TransactionTest.py index 257eb377..6827720d 100644 --- a/test/python/TransactionTest.py +++ b/test/python/TransactionTest.py @@ -6,18 +6,33 @@ import operator from ledger import * from datetime import * -class JournalTestCase(unittest.TestCase): +class TransactionTestCase(unittest.TestCase): def setUp(self): - pass + self.journal = read_journal_from_string(""" +2012-03-01 KFC + Expenses:Food $21.34 + Assets:Cash +2012-03-02 MJT + Expenses:Museum $45.67 + Assets:Cash +""") def tearDown(self): close_journal_files() - def test_(self): - pass - + def testAddRemovePosts(self): + xacts = [xact for xact in self.journal] + x1_posts = [post for post in xacts[1]] + for post in x1_posts: + xacts[0].add_post(post) + xacts[1].remove_post(post) + x0_posts = [post for post in xacts[0]] + x1_posts = [post for post in xacts[1]] + self.assertEqual(len(x0_posts), 4) + self.assertEqual(len(x1_posts), 0) + def suite(): - return unittest.TestLoader().loadTestsFromTestCase(JournalTestCase) + return unittest.TestLoader().loadTestsFromTestCase(TransactionTestCase) if __name__ == '__main__': unittest.main() |