Skip to content

Commit ca44e26

Browse files
eduralphGaryGriffin
authored andcommitted
ImportGramplet: look up imported person by handle, not gramps_id
The death-fallback test fetched the imported person with get_person_from_gramps_id("I00001"), but core's XML importer normalises gramps_ids to the database's configured width — under the default "I%04d" the fixture's "I00001" becomes "I0001" — so the literal lookup returned None and the test failed on every default-config tree (reported by GaryGriffin on macOS; reproduced here against maintenance/gramps60 and on Linux). Exactly one person is imported, so fetch it by handle instead. This removes the dependency on gramps_id formatting; the death/birth assertions already resolve their events by handle. The fix wiring under test is unchanged — the death_ref is correctly set on clean XML, confirming bug 13420 does not reproduce on conformant input. Verified: 1 test OK against maintenance/gramps60 (direct unittest and gramps-testbed addon-unit runner). Bug #13420
1 parent 57e38ba commit ca44e26

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

ImportGramplet/tests/test_xml_death_fallback.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,16 @@ def test_clean_xml_imports_set_death_ref_via_atomic_parser(self):
154154
ifile = BytesIO(CLEAN_XML.encode("utf-8"))
155155
parser.parse(ifile)
156156

157-
person = self.database.get_person_from_gramps_id("I00001")
158-
self.assertIsNotNone(
159-
person,
160-
"Person I00001 must exist after XML import",
157+
# Look the person up by handle, not by gramps_id: core's importer
158+
# normalises gramps_ids to the database's configured width (the XML
159+
# "I00001" becomes "I0001" under the default "I%04d"), so a literal
160+
# gramps_id lookup is brittle and fails on any default-config tree.
161+
# Exactly one person was imported, so fetch it directly.
162+
handles = list(self.database.get_person_handles())
163+
self.assertEqual(
164+
len(handles), 1, "exactly one person must be imported"
161165
)
166+
person = self.database.get_person_from_handle(handles[0])
162167

163168
death_ref = person.get_death_ref()
164169
self.assertIsNotNone(

0 commit comments

Comments
 (0)