def test_citation_should_encode_full(self): citation = Citation('the_citation', Source('the_source', 'The Source')) citation.description = 'The Source Description' citation.facts.append(IdentifiableEvent('the_event', Event.Type.BIRTH)) expected = { '$schema': '/schema.json#/definitions/citation', '@type': 'https://schema.org/Thing', 'id': 'the_citation', 'source': '/source/the_source/index.json', 'facts': ['/event/the_event/index.json'], } self.assert_encodes(expected, citation, 'citation')
def _parse_citation(ancestry: _IntermediateAncestry, element: Element) -> None: handle = _xpath1(element, './@handle') citation = Citation(_xpath1(element, './@id')) _parse_objref(ancestry, citation, element) page = _xpath1(element, './ns:page') if page is not None: citation.description = page.text source_handle = _xpath1(element, './ns:sourceref/@hlink') if source_handle is not None: citation.source = ancestry.sources[source_handle] ancestry.citations[handle] = citation