def test_untlpy2dcpy_resolve_values_retrieve_vocab(mock_vocab): mock_vocab.return_value = { 'languages': [{ 'url': 'http://example.com/languages/#spa', 'name': 'spa', 'label': 'Spanish' }] } untl_dict = {'language': [{'content': 'spa'}]} untl_elements = untldoc.untldict2py(untl_dict) root = untldoc.untlpy2dcpy(untl_elements, resolve_values=True) assert root.children[0].tag == 'language' assert root.children[0].content == 'Spanish'
def test_untlpy2dcpy(): untl_dict = { 'coverage': [{ 'content': '1943', 'qualifier': 'sDate' }, { 'content': '1944', 'qualifier': 'eDate' }, { 'content': 'United States - Texas', 'qualifier': 'placeName' }], 'publisher': [{ 'content': { 'name': 'UNT Press', 'location': 'Denton, Texas' } }], 'creator': [{ 'content': { 'type': 'org', 'name': 'UNT' }, 'qualifier': 'aut' }], 'title': [{ 'content': 'UNT Book', 'qualifier': 'officialtitle' }], 'collection': [{ 'content': 'UNT' }] } untl_elements = untldoc.untldict2py(untl_dict) root = untldoc.untlpy2dcpy(untl_elements) assert isinstance(root, dc.DCElement) assert len(root.children) == 5 assert root.tag == 'dc' assert root.children[0].tag == 'coverage' assert root.children[0].content == 'United States - Texas' assert root.children[1].tag == 'publisher' assert root.children[1].content == 'UNT Press' assert root.children[2].tag == 'creator' assert root.children[2].content == 'UNT' assert root.children[3].tag == 'title' assert root.children[3].content == 'UNT Book' # Coverage sDate/eDate are combined and added at the end. assert root.children[4].tag == 'coverage' assert root.children[4].content == '1943-1944'
def test_untlpy2dcpy_resolve_urls(): verbose_vocab = { 'languages': [{ 'url': 'http://example.com/languages/#spa', 'name': 'spa', 'label': 'Spanish' }] } untl_dict = {'language': [{'content': 'spa'}]} untl_elements = untldoc.untldict2py(untl_dict) root = untldoc.untlpy2dcpy(untl_elements, resolve_urls=True, verbose_vocabularies=verbose_vocab) assert root.children[0].tag == 'language' assert root.children[0].content == 'http://example.com/languages/#spa'
def test_untlpy2dcpy_add_permalink_and_ark(): untl_dict = { 'title': [{ 'content': 'UNT Book', 'qualifier': 'officialtitle' }] } untl_elements = untldoc.untldict2py(untl_dict) root = untldoc.untlpy2dcpy(untl_elements, ark='ark:/67531/metatest1', domain_name='example.com', scheme='https') assert root.children[0].tag == 'title' assert root.children[1].tag == 'identifier' assert root.children[ 1].content == 'https://example.com/ark:/67531/metatest1/' assert root.children[2].tag == 'identifier' assert root.children[2].content == 'ark: ark:/67531/metatest1'
def test_untlpy2dcpy_only_eDate(): untl_dict = {'coverage': [{'content': '1955', 'qualifier': 'eDate'}]} untl_elements = untldoc.untldict2py(untl_dict) root = untldoc.untlpy2dcpy(untl_elements) assert root.children[0].tag == 'coverage' assert root.children[0].content == '1955'
def setUp(self): """Set up the initial data.""" self.root_element = untlpy2dcpy(untldict2py(UNTL_DICT))