summaryrefslogtreecommitdiff
path: root/test/python
diff options
context:
space:
mode:
Diffstat (limited to 'test/python')
-rw-r--r--test/python/JournalTest.py30
-rw-r--r--test/python/PostingTest.py25
-rw-r--r--test/python/TransactionTest.py25
-rw-r--r--test/python/UnitTests.py12
4 files changed, 92 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()
diff --git a/test/python/PostingTest.py b/test/python/PostingTest.py
new file mode 100644
index 00000000..f191253e
--- /dev/null
+++ b/test/python/PostingTest.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+import exceptions
+import operator
+
+from ledger import *
+from StringIO import *
+from datetime import *
+
+class PostingTestCase(unittest.TestCase):
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def test_(self):
+ pass
+
+def suite():
+ return unittest.TestLoader().loadTestsFromTestCase(PostingTestCase)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/python/TransactionTest.py b/test/python/TransactionTest.py
new file mode 100644
index 00000000..66447f87
--- /dev/null
+++ b/test/python/TransactionTest.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+import exceptions
+import operator
+
+from ledger import *
+from StringIO import *
+from datetime import *
+
+class JournalTestCase(unittest.TestCase):
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def test_(self):
+ pass
+
+def suite():
+ return unittest.TestLoader().loadTestsFromTestCase(JournalTestCase)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/python/UnitTests.py b/test/python/UnitTests.py
new file mode 100644
index 00000000..388e2229
--- /dev/null
+++ b/test/python/UnitTests.py
@@ -0,0 +1,12 @@
+from unittest import TextTestRunner, TestSuite
+
+import JournalTest
+import TransactionTest
+import PostingTest
+
+suites = [
+ JournalTest.suite(),
+ TransactionTest.suite(),
+ PostingTest.suite()
+]
+TextTestRunner().run(TestSuite(suites))