add basic test for python query

add test for creating query object and setting search_for
related to Bug 796137 and fix in commit 1a7c5b9a32
This commit is contained in:
Christoph Holtermann 2018-09-20 18:39:05 +02:00
parent 2d565215cd
commit 54cb3358ce
3 changed files with 26 additions and 1 deletions

View File

@ -22,6 +22,7 @@ set(test_python_bindings_DATA
test_commodity.py
test_numeric.py
test_split.py
test_transaction.py)
test_transaction.py
test_query.py)
set_dist_list(test_python_bindings_DIST CMakeLists.txt ${test_python_bindings_DATA})

View File

@ -12,6 +12,7 @@ from test_transaction import TestTransaction
from test_business import TestBusiness
from test_commodity import TestCommodity, TestCommodityNamespace
from test_numeric import TestGncNumeric
from test_query import TestQuery
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,23 @@
from unittest import TestCase, main
from gnucash import Query
from gnucash.gnucash_core_c import GNC_ID_INVOICE
class TestQuery(TestCase):
def test_create(self):
query = Query()
self.assertIsInstance(query, Query)
def test_search_for(self):
query = Query()
query.search_for(GNC_ID_INVOICE)
self.assertEqual(query.get_search_for(), GNC_ID_INVOICE)
obj_type = 'gncInvoice'
query.search_for(obj_type)
self.assertEqual(query.get_search_for(), obj_type)
if __name__ == '__main__':
main()