diff options
Diffstat (limited to 'test/python/JournalTest.py')
-rw-r--r-- | test/python/JournalTest.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/python/JournalTest.py b/test/python/JournalTest.py new file mode 100644 index 00000000..e65c671d --- /dev/null +++ b/test/python/JournalTest.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +import unittest + +from ledger import * + +class JournalTestCase(unittest.TestCase): + def tearDown(self): + session.close_journal_files() + + def testBasicRead(self): + journal = read_journal_from_string(""" +2012-03-01 KFC + Expenses:Food $21.34 + Assets:Cash +""") + self.assertEqual(type(journal), Journal) + + for xact in journal: + self.assertEqual(xact.payee, "KFC") + + for post in journal.query("food"): + self.assertEqual(str(post.account), "Expenses:Food") + self.assertEqual(post.amount, Amount("$21.34")) + +def suite(): + return unittest.TestLoader().loadTestsFromTestCase(JournalTestCase) + +if __name__ == '__main__': + unittest.main() |