* src/EditPlace.py: changed display_references to use find_backlink_handles
* src/EditRepository.py: modified to use find_backlink_handles and fixed subtle bug * src/RelLib/_Source.py: added reporef_list to referent object lists so that backref are put in reference_map * test/GrampsDb/GrampsDbBase_Test.py: added unittest for source/reference backlinks * test/GrampsDb/GrampsDbTestBase.py: added unittest for source/reference backlinks svn: r5616
This commit is contained in:
@ -89,6 +89,17 @@ class ReferenceMapTest (GrampsDbBaseTest):
|
||||
assert len(references) == 1
|
||||
assert references[0] == (RelLib.Person.__name__,person.get_handle())
|
||||
|
||||
def test_backlink_for_repository(self):
|
||||
"""check that the source / repos backlink lookup works."""
|
||||
|
||||
repos = self._add_repository()
|
||||
source = self._add_source(repos=repos)
|
||||
|
||||
references = [ ref for ref in self._db.find_backlink_handles(repos.get_handle()) ]
|
||||
|
||||
assert len(references) == 1
|
||||
assert references[0] == (RelLib.Source.__name__,source.get_handle())
|
||||
|
||||
def test_class_limited_lookup(self):
|
||||
"""check that class limited lookups work."""
|
||||
|
||||
|
@ -79,17 +79,32 @@ class GrampsDbBaseTest(unittest.TestCase):
|
||||
|
||||
return
|
||||
|
||||
def _add_source(self):
|
||||
def _add_source(self,repos=None):
|
||||
# Add a Source
|
||||
|
||||
tran = self._db.transaction_begin()
|
||||
source = RelLib.Source()
|
||||
if repos != None:
|
||||
repo_ref = RelLib.RepoRef()
|
||||
repo_ref.set_reference_handle(repos.get_handle())
|
||||
source.add_repo_reference(repo_ref)
|
||||
self._db.add_source(source,tran)
|
||||
self._db.commit_source(source,tran)
|
||||
self._db.transaction_commit(tran, "Add Source")
|
||||
|
||||
return source
|
||||
|
||||
def _add_repository(self):
|
||||
# Add a Repository
|
||||
|
||||
tran = self._db.transaction_begin()
|
||||
repos = RelLib.Repository()
|
||||
self._db.add_repository(repos,tran)
|
||||
self._db.commit_repository(repos,tran)
|
||||
self._db.transaction_commit(tran, "Add Repository")
|
||||
|
||||
return repos
|
||||
|
||||
|
||||
def _add_object_with_source(self,sources,object_class,add_method,commit_method):
|
||||
|
||||
|
Reference in New Issue
Block a user