def test_privatize_person_should_privatize_if_private(self): source_file = File('F0', __file__) source = Source('The Source') source.files.append(source_file) citation_file = File('F1', __file__) citation = IdentifiableCitation('C0', source) citation.files.append(citation_file) event_as_subject = Event(Birth()) event_as_attendee = Event(Marriage()) person_file = File('F2', __file__) person = Person('P0') person.private = True person.citations.append(citation) person.files.append(person_file) Presence(person, Subject(), event_as_subject) Presence(person, Attendee(), event_as_attendee) privatize_person(person, 125) self.assertTrue(person.private) self.assertTrue(citation.private) self.assertTrue(source.private) self.assertTrue(person_file.private) self.assertTrue(citation_file.private) self.assertTrue(source_file.private) self.assertTrue(event_as_subject.private) self.assertIsNone(event_as_attendee.private)
def test_privatize_person_should_not_privatize_if_public(self): source_file = File('F0', __file__) source = Source('The Source') source.files.append(source_file) citation_file = File('F1', __file__) citation = IdentifiableCitation('C0', source) citation.files.append(citation_file) event_as_subject = Event(Birth()) event_as_attendee = Event(Marriage()) person_file = File('F2', __file__) person = Person('P0') person.private = False person.citations.append(citation) person.files.append(person_file) Presence(person, Subject(), event_as_subject) Presence(person, Attendee(), event_as_attendee) ancestry = Ancestry() ancestry.people[person.id] = person privatize(ancestry) self.assertEqual(False, person.private) self.assertIsNone(citation.private) self.assertIsNone(source.private) self.assertIsNone(person_file.private) self.assertIsNone(citation_file.private) self.assertIsNone(source_file.private) self.assertIsNone(event_as_subject.private) self.assertIsNone(event_as_attendee.private)
def _parse_eventref(ancestry: _IntermediateAncestry, person: Person, eventref: Element) -> None: event_handle = _xpath1(eventref, './@hlink') gramps_presence_role = _xpath1(eventref, './@role') role = _PRESENCE_ROLE_MAP[ gramps_presence_role] if gramps_presence_role in _PRESENCE_ROLE_MAP else Attendee( ) Presence(person, role, ancestry.events[event_handle])
class TestWitnessRoleTest(TemplateTestCase): @parameterized.expand([ ('true', Witness()), ('false', Witness), ('false', Attendee()), ('false', 9), ]) @sync async def test(self, expected, data) -> None: template = '{% if data is witness_role %}true{% else %}false{% endif %}' async with self._render(template_string=template, data={ 'data': data, }) as (actual, _): self.assertEquals(expected, actual)
def test_label(self) -> None: sut = Attendee() with Translations(NullTranslations()): self.assertIsInstance(sut.label, str) self.assertNotEqual('', sut.label)
def test_name(self) -> None: self.assertIsInstance(Attendee.name(), str) self.assertNotEqual('', Attendee.name)
def _load_eventref(loader: _Loader, person: Person, eventref: ElementTree.Element) -> None: event_handle = eventref.get('hlink') gramps_presence_role = eventref.get('role') role = _PRESENCE_ROLE_MAP[gramps_presence_role] if gramps_presence_role in _PRESENCE_ROLE_MAP else Attendee() Presence(person, role, loader._events[event_handle])
for parent in parents: parent.children.append(child) def _load_eventrefs(loader: _Loader, person: Person, element: ElementTree.Element) -> None: eventrefs = _xpath(element, './ns:eventref') for eventref in eventrefs: _load_eventref(loader, person, eventref) _PRESENCE_ROLE_MAP = { 'Primary': Subject(), 'Family': Subject(), 'Witness': Witness(), 'Beneficiary': Beneficiary(), 'Unknown': Attendee(), } def _load_eventref(loader: _Loader, person: Person, eventref: ElementTree.Element) -> None: event_handle = eventref.get('hlink') gramps_presence_role = eventref.get('role') role = _PRESENCE_ROLE_MAP[gramps_presence_role] if gramps_presence_role in _PRESENCE_ROLE_MAP else Attendee() Presence(person, role, loader._events[event_handle]) def _load_places(loader: _Loader, database: ElementTree.Element): intermediate_places = {handle: intermediate_place for handle, intermediate_place in [_load_place(element) for element in _xpath(database, './ns:places/ns:placeobj')]} for intermediate_place in intermediate_places.values(): for enclosed_by_handle in intermediate_place.enclosed_by_handles: