Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 def test_label(self) -> None:
     sut = Attendee()
     with Translations(NullTranslations()):
         self.assertIsInstance(sut.label, str)
         self.assertNotEqual('', sut.label)
Ejemplo n.º 5
0
 def test_name(self) -> None:
     self.assertIsInstance(Attendee.name(), str)
     self.assertNotEqual('', Attendee.name)
Ejemplo n.º 6
0
                                   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)