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 = Citation('C0', source) citation.files.append(citation_file) event_as_subject = Event(None, Birth()) event_as_attendee = Event(None, 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) ancestry = Ancestry() ancestry.entities.append(person) privatize(ancestry) 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 _load_eventref(loader: _Loader, person_id: str, 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 = Presence(None, role, None) identifiable_presence = FlattenedEntity(presence) loader.add_entity(identifiable_presence) loader.add_association(Presence, identifiable_presence.id, 'person', Person, person_id) loader.add_association(Presence, identifiable_presence.id, 'event', Event, 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)
parent_handle) def _load_eventrefs(loader: _Loader, person_id: str, element: ElementTree.Element) -> None: eventrefs = _xpath(element, './ns:eventref') for eventref in eventrefs: _load_eventref(loader, person_id, eventref) _PRESENCE_ROLE_MAP = { 'Primary': Subject(), 'Family': Subject(), 'Witness': Witness(), 'Beneficiary': Beneficiary(), 'Unknown': Attendee(), } def _load_eventref(loader: _Loader, person_id: str, 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 = Presence(None, role, None) identifiable_presence = FlattenedEntity(presence) loader.add_entity(identifiable_presence) loader.add_association(Presence, identifiable_presence.id, 'person', Person, person_id)