From 11942d8975cbff9151a2dba809786d060ec93d4c Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Tue, 29 Nov 2016 22:30:11 +0000 Subject: [PATCH] Add database unit tests for sorted handles --- gramps/plugins/db/dbapi/test/db_test.py | 44 +++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/gramps/plugins/db/dbapi/test/db_test.py b/gramps/plugins/db/dbapi/test/db_test.py index a5f84a981..4c99ae29f 100644 --- a/gramps/plugins/db/dbapi/test/db_test.py +++ b/gramps/plugins/db/dbapi/test/db_test.py @@ -144,8 +144,12 @@ class DbRandomTest(unittest.TestCase): # Test get_*_handles methods # ################################################################ - def __get_handles_test(self, obj_type, handles_func, number_func): - handles = handles_func() + def __get_handles_test(self, obj_type, handles_func, number_func, + sort_handles=False): + if sort_handles: + handles = handles_func(sort_handles=True) + else: + handles = handles_func() self.assertEqual(len(handles), number_func()) for handle in handles: self.assertIn(handle.decode('utf8'), self.handles[obj_type]) @@ -200,6 +204,42 @@ class DbRandomTest(unittest.TestCase): self.db.get_tag_handles, self.db.get_number_of_tags) + def test_get_person_handles_sort(self): + self.__get_handles_test('Person', + self.db.get_person_handles, + self.db.get_number_of_people, + sort_handles=True) + + def test_get_family_handles_sort(self): + self.__get_handles_test('Family', + self.db.get_family_handles, + self.db.get_number_of_families, + sort_handles=True) + + def test_get_source_handles_sort(self): + self.__get_handles_test('Source', + self.db.get_source_handles, + self.db.get_number_of_sources, + sort_handles=True) + + def test_get_citation_handles_sort(self): + self.__get_handles_test('Citation', + self.db.get_citation_handles, + self.db.get_number_of_citations, + sort_handles=True) + + def test_get_media_handles_sort(self): + self.__get_handles_test('Media', + self.db.get_media_handles, + self.db.get_number_of_media, + sort_handles=True) + + def test_get_tag_handles_sort(self): + self.__get_handles_test('Tag', + self.db.get_tag_handles, + self.db.get_number_of_tags, + sort_handles=True) + ################################################################ # # Test get_*_gramps_ids methods