tests and fixes for reference_map.

svn: r5576
This commit is contained in:
Richard Taylor 2005-12-17 22:16:03 +00:00
parent 9f891c2913
commit 56d3c6658c
3 changed files with 38 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2005-12-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsBSDDB.py: fixed backlinks search to return classname rather
than index.
* test/GrampsDbBase_Test.py: added test for limiting classes
returned from backlink search
2005-12-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsBSDDB.py: reference_map now uses keys rather
than class names

View File

@ -464,7 +464,7 @@ class GrampsBSDDB(GrampsDbBase):
data = cPickle.loads(data)
if include_classes == None or KEY_TO_CLASS_MAP[data[0][0]] in include_classes:
yield data[0]
yield (KEY_TO_CLASS_MAP[data[0][0]],data[0][1])
ret = referenced_cur.next_dup()

View File

@ -153,7 +153,37 @@ class ReferenceMapTest (unittest.TestCase):
references = [ ref for ref in self._db.find_backlink_handles(source.get_handle()) ]
assert len(references) == 1
assert references[0] == (GrampsBSDDB.CLASS_TO_KEY_MAP[RelLib.Person.__name__],person.get_handle())
assert references[0] == (RelLib.Person.__name__,person.get_handle())
def test_class_limited_lookup(self):
"""check that class limited lookups work."""
source = self._add_source()
person = self._add_person_with_sources([source])
self._add_family_with_sources([source])
self._add_event_with_sources([source])
self._add_place_with_sources([source])
self._add_media_object_with_sources([source])
# make sure that we have the correct number of references (one for each object)
references = [ ref for ref in self._db.find_backlink_handles(source.get_handle()) ]
assert len(references) == 5, "len(references) == %s " % str(len(references))
# should just return the person reference
references = [ ref for ref in self._db.find_backlink_handles(source.get_handle(),(RelLib.Person.__name__,)) ]
assert len(references) == 1, "len(references) == %s " % str(len(references))
assert references[0][0] == RelLib.Person.__name__, "references = %s" % repr(references)
# should just return the person and event reference
references = [ ref for ref in self._db.find_backlink_handles(source.get_handle(),(RelLib.Person.__name__,
RelLib.Event.__name__)) ]
assert len(references) == 2, "len(references) == %s " % str(len(references))
assert references[0][0] == RelLib.Person.__name__, "references = %s" % repr(references)
assert references[1][0] == RelLib.Event.__name__, "references = %s" % repr(references)
def test_delete_primary(self):
"""check that deleting a primary will remove the backreferences
@ -202,14 +232,6 @@ class ReferenceMapTest (unittest.TestCase):
assert len(references) == 1, "len(references) == %s " % str(len(references))
def _timeit(func,*args,**kwargs):
start = time.time()
func(*args,**kwargs)
end = time.time()
return end - start
def perf_simple_search_speed(self):