Fix get_total method and add unit tests
This commit is contained in:
parent
35b7495438
commit
3e69fa5cbe
@ -1960,17 +1960,19 @@ class DbWriteBase(DbReadBase):
|
|||||||
"""
|
"""
|
||||||
Get the total of primary objects.
|
Get the total of primary objects.
|
||||||
"""
|
"""
|
||||||
# TODO: should this include tags and citations?
|
|
||||||
person_len = self.get_number_of_people()
|
person_len = self.get_number_of_people()
|
||||||
family_len = self.get_number_of_families()
|
family_len = self.get_number_of_families()
|
||||||
event_len = self.get_number_of_events()
|
event_len = self.get_number_of_events()
|
||||||
source_len = self.get_number_of_sources()
|
|
||||||
place_len = self.get_number_of_places()
|
place_len = self.get_number_of_places()
|
||||||
repo_len = self.get_number_of_repositories()
|
repo_len = self.get_number_of_repositories()
|
||||||
obj_len = self.get_number_of_media()
|
source_len = self.get_number_of_sources()
|
||||||
|
citation_len = self.get_number_of_citations()
|
||||||
|
media_len = self.get_number_of_media()
|
||||||
|
note_len = self.get_number_of_notes()
|
||||||
|
tag_len = self.get_number_of_tags()
|
||||||
|
|
||||||
return person_len + family_len + event_len + \
|
return (person_len + family_len + event_len + place_len + repo_len +
|
||||||
place_len + source_len + obj_len + repo_len
|
source_len + citation_len + media_len + note_len + tag_len)
|
||||||
|
|
||||||
def set_birth_death_index(self, person):
|
def set_birth_death_index(self, person):
|
||||||
"""
|
"""
|
||||||
|
@ -687,6 +687,16 @@ class DbRandomTest(unittest.TestCase):
|
|||||||
person = self.db.find_initial_person()
|
person = self.db.find_initial_person()
|
||||||
self.assertEqual(person.handle, default_handle)
|
self.assertEqual(person.handle, default_handle)
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# Test get_total method
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
def test_get_total(self):
|
||||||
|
total = sum([len(self.handles[obj_type])
|
||||||
|
for obj_type in self.handles.keys()])
|
||||||
|
self.assertEqual(self.db.get_total(), total)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# DbEmptyTest class
|
# DbEmptyTest class
|
||||||
@ -776,6 +786,14 @@ class DbEmptyTest(unittest.TestCase):
|
|||||||
mapping = self.db.get_name_group_mapping('Clark')
|
mapping = self.db.get_name_group_mapping('Clark')
|
||||||
self.assertEqual(mapping, 'Clarke')
|
self.assertEqual(mapping, 'Clarke')
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# Test get_total method
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
def test_get_total(self):
|
||||||
|
self.assertEqual(self.db.get_total(), 0)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# DbPersonTest class
|
# DbPersonTest class
|
||||||
|
Loading…
Reference in New Issue
Block a user