Ejemplo n.º 1
0
 def test_place_should_sync_references(self):
     place = Place('1', 'one')
     sut = Event('1', Event.Type.BIRTH)
     sut.place = place
     self.assertEquals(place, sut.place)
     self.assertIn(sut, place.events)
     sut.place = None
     self.assertEquals(None, sut.place)
     self.assertNotIn(sut, place.events)
Ejemplo n.º 2
0
 def test_place(self) -> None:
     place = Place('1', [PlaceName('one')])
     sut = Event(Mock(EventType))
     sut.place = place
     self.assertEquals(place, sut.place)
     self.assertIn(sut, place.events)
     sut.place = None
     self.assertEquals(None, sut.place)
     self.assertNotIn(sut, place.events)
Ejemplo n.º 3
0
    def setUpClass(cls):
        cls._outputDirectory = TemporaryDirectory()
        configuration = Configuration(cls._outputDirectory.name,
                                      'https://ancestry.example.com')
        cls.site = Site(configuration)

        place1 = Place('PLACE1', 'one')

        event1 = Event('EVENT1', Event.Type.BIRTH)
        event1.place = place1

        event1_person_1_presence = Presence(Presence.Role.SUBJECT)
        event1_person_1_presence.event = event1

        person1 = Person('PERSON1', 'Janet', 'Dough')
        person1.presences.add(event1_person_1_presence)

        source1 = Source('SOURCE1', 'A Little Birdie')

        places = [place1]
        cls.site.ancestry.places.update({place.id: place for place in places})
        events = [event1]
        cls.site.ancestry.events.update({event.id: event for event in events})
        people = [person1]
        cls.site.ancestry.people.update(
            {person.id: person
             for person in people})
        sources = [source1]
        cls.site.ancestry.sources.update(
            {source.id: source
             for source in sources})

        render(cls.site)
 async def test_with_place(self):
     event = Event(Birth())
     event.place = Place('P0', [PlaceName('The Place')])
     expected = 'in <address><a href="/place/P0/index.html"><span>The Place</span></a></address>'
     async with self._render(data={
         'event': event,
     }) as (actual, _):
         self.assertEqual(expected, actual)
 async def test_with_place_is_place_context(self):
     event = Event(Birth())
     place = Place('P0', [PlaceName('The Place')])
     event.place = place
     expected = ''
     async with self._render(data={
         'event': event,
         'place_context': place,
     }) as (actual, _):
         self.assertEqual(expected, actual)
 async def test_embedded(self):
     event = Event(Birth())
     event.date = Date(1970)
     event.place = Place('P0', [PlaceName('The Place')])
     event.citations.append(Citation(Source('The Source')))
     expected = '1970 in <address><span>The Place</span></address>'
     async with self._render(data={
         'event': event,
         'embedded': True,
     }) as (actual, _):
         self.assertEqual(expected, actual)
Ejemplo n.º 7
0
def _parse_event(ancestry: _IntermediateAncestry, element: Element):
    handle = str(_xpath1(element, './@handle'))
    gramps_type = _xpath1(element, './ns:type')

    event = Event(_xpath1(element, './@id'), _EVENT_TYPE_MAP[gramps_type.text])

    event.date = _parse_date(element)

    # Parse the event place.
    place_handle = _xpath1(element, './ns:place/@hlink')
    if place_handle:
        event.place = ancestry.places[place_handle]

    _parse_objref(ancestry, event, element)

    citation_handles = _xpath(element, './ns:citationref/@hlink')
    for citation_handle in citation_handles:
        event.citations.add(ancestry.citations[citation_handle])
    ancestry.events[handle] = event