def test_rero_authorized_access_point(): """Test Authorized access point representing a person 100 $adc""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="a">Brontë, Charlotte,</subfield> <subfield code="d">1816-1855</subfield> <subfield code="c">écrivain</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_authorized_access_point() assert trans.json == { 'authorized_access_point': 'Brontë, Charlotte, 1816-1855 écrivain', 'bf:Agent': 'bf:Person' } xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="a">Paul</subfield> <subfield code="b">VI</subfield> <subfield code="c">pape</subfield> <subfield code="d">1897-1978</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_authorized_access_point() assert trans.json == { 'authorized_access_point': 'Paul VI pape 1897-1978', 'bf:Agent': 'bf:Person' }
def test_gnd_conference(): """Test conference false: 075 $b = b true: 075 $b = f""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="075"> <subfield code="b">b</subfield> </datafield> <datafield ind1=" " ind2=" " tag="111"> <subfield code="a">test</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_conference() assert trans.json == {'conference': False} xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="075"> <subfield code="b">f</subfield> </datafield> <datafield ind1=" " ind2=" " tag="111"> <subfield code="a">test</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_conference() assert trans.json == {'conference': True} xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="075"> <subfield code="b">x</subfield> </datafield> <datafield ind1=" " ind2=" " tag="111"> <subfield code="a">test</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_conference() assert trans.json is None
def test_idref_birth_and_death_from_field_103(): """Test date of birth 103 $a pos. 1-8 YYYYMMDD""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="103"> <subfield code="a">18160421</subfield> <subfield code="b">18550331</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_birth_and_death_dates() assert trans.json == { 'date_of_birth': '1816-04-21', 'date_of_death': '1855-03-31' } xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="103"> <subfield code="a">18160421</subfield> <subfield code="b">1855</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_birth_and_death_dates() assert trans.json == { 'date_of_birth': '1816-04-21', 'date_of_death': '1855' }
def test_gnd_deleted(): """Test deleted -> leader 6 == d.""" xml_part_to_add = """ <leader>00000nz a2200000oc 4500</leader> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_deleted() assert not trans.json xml_part_to_add = """ <leader>00000cz a2200000oc 4500</leader> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_deleted() assert 'deleted' in trans.json xml_part_to_add = """ <leader>00000xz a2200000oc 4500</leader> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_deleted() assert 'deleted' in trans.json xml_part_to_add = """ <leader>00000dz a2200000oc 4500</leader> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_deleted() assert 'deleted' in trans.json
def test_idref_parallel_access_point(): """Test parallel access point 700/710/710.""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="700"> <subfield code="a">Brontë, Charlotte,</subfield> <subfield code="d">1816-1855</subfield> <subfield code="c">écrivain</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_parallel_access_point() assert trans.json == { 'parallel_access_point': ['Brontë, Charlotte, 1816-1855, écrivain'] } xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="710"> <subfield code="a">Paul</subfield> <subfield code="b">VI</subfield> <subfield code="c">pape</subfield> <subfield code="d">1897-1978</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_parallel_access_point() assert trans.json == { 'parallel_access_point': ['Paul. VI ( pape ) ( 1897-1978 )'] }
def test_idref_authorized_access_point(): """Test Authorized access point representing a person 200 $abcdf""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="200"> <subfield code="a">Brontë</subfield> <subfield code="b">Charlotte</subfield> <subfield code="c">écrivain</subfield> <subfield code="c">biographe</subfield> <subfield code="f">1816-1855</subfield> <subfield code="e">ignorer</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_authorized_access_point() assert trans.json == { 'authorized_access_point': 'Brontë, Charlotte, écrivain, biographe, 1816-1855', 'bf:Agent': 'bf:Person' } """Test Authorized access point representing a organisation 210 $ab9""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="210"> <subfield code="9">0</subfield> <subfield code="a">Stift Alter Dom Sankt Pauli</subfield> <subfield code="c">Münster in Westfalen, Allemagne</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_authorized_access_point() assert trans.json == { 'authorized_access_point': 'Stift Alter Dom Sankt Pauli ( Münster in ' 'Westfalen, Allemagne )', 'bf:Agent': 'bf:Organisation', 'conference': False, } """Test Authorized access point representing a organisation 210 $ab9""" xml_part_to_add = """ <datafield ind1="1" ind2=" " tag="210"> <subfield code="9">0</subfield> <subfield code="a">Stift Alter Dom Sankt Pauli</subfield> <subfield code="c">Münster in Westfalen, Allemagne</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_authorized_access_point() assert trans.json == { 'authorized_access_point': 'Stift Alter Dom Sankt Pauli ( Münster in ' 'Westfalen, Allemagne )', 'bf:Agent': 'bf:Organisation', 'conference': True, }
def test_idref_birth_and_death_dates_in_two_fields(): """Test date of birth 103 $a pos. 1-8 YYYYMMDD AND 200 $f pos. 1-4""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="103"> <subfield code="a">18160421</subfield> <subfield code="b">18550331</subfield> </datafield> <datafield ind1=" " ind2=" " tag="200"> <subfield code="f">1816-1855</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_birth_and_death_dates() assert trans.json == { 'date_of_birth': '1816-04-21', 'date_of_death': '1855-03-31' } xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="103"> <subfield code="a">1525</subfield> <subfield code="b">16010723</subfield> </datafield> <datafield ind1=" " ind2=" " tag="200"> <subfield code="f">1525?-1601</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_birth_and_death_dates() assert trans.json == { 'date_of_birth': '1525', 'date_of_death': '1601-07-23' } xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="103"> <subfield code="a">1525</subfield> <subfield code="b">16010723</subfield> </datafield> <datafield ind1=" " ind2=" " tag="200"> <subfield code="f">1525?-1601</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_birth_and_death_dates() assert trans.json == { 'date_of_birth': '1525', 'date_of_death': '1601-07-23' }
def test_idref_deleted(): """Test deleted -> leader 6 == d.""" xml_part_to_add = """ <leader> dx a22 3 45 </leader> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_deleted() assert 'deleted' in trans.json xml_part_to_add = """ <leader> cx a22 3 45 </leader> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_deleted() assert not trans.json
def test_gnd_authorized_access_point_missing(): """Test Authorized access point representing a person 100 $abcd missing """ xml_part_to_add = "" trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_authorized_access_point() assert not trans.json
def test_idref_relation_pid(): """Test old pids 035 $a $9 == 'sudoc'.""" xml_part_to_add = """ <datafield tag="035" ind1=" " ind2=" "> <subfield code="a">027630501</subfield> <subfield code="9">sudoc</subfield> </datafield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="a">frBN001940328</subfield> </datafield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="a">frBN000000089</subfield> </datafield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="a">FRBNF118620892</subfield> <subfield code="z">FRBNF11862089</subfield> </datafield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="a">http://viaf.org/viaf/124265140</subfield> <subfield code="2">VIAF</subfield> <subfield code="C">VIAF</subfield> <subfield code="d">20200302</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_relation_pid() assert trans.json == { 'relation_pid': { 'value': '027630501', 'type': 'redirect_from' } }
def test_idref_variant_name_missing(): """Test Variant Name for Person 400 $ab missing""" xml_part_to_add = "" trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_variant_name() trans.trans_idref_variant_access_point() assert not trans.json
def test_idref_pid(): """Test pid for person""" xml_part_to_add = """ <controlfield tag="001">069774331</controlfield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_pid() assert trans.json == {'pid': '069774331'}
def test_idref_identifier(): """Test identifier for person""" xml_part_to_add = """ <controlfield tag="003">http://www.idref.fr/069774331</controlfield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_identifier() assert trans.json == {'identifier': 'http://www.idref.fr/069774331'}
def test_trans_idref_qualifier(): """Test numeration for Person 200 $c""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="200"> <subfield code="c">Jr.</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_qualifier() assert trans.json == {'qualifier': 'Jr.'}
def test_gnd_pid(): """Test pid for person""" xml_part_to_add = """ <controlfield tag="001">118577166</controlfield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_pid() assert trans.json == { 'pid': '118577166', }
def test_gnd_birth_and_death_dates_year_death(): """Test date of birth 100 $d -YYYY""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="d">-1855</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_birth_and_death_dates() assert trans.json == {'date_of_death': '1855'}
def test_idref_birth_and_death_dates_year_birth(): """Test date of birth 103 $a pos. 1-8 YYYYMMDD""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="103"> <subfield code="a">1816?</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_birth_and_death_dates() assert trans.json == {'date_of_birth': '1816?'}
def test_gnd_preferred_name(): """Test Preferred Name for Person 100 $a""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="a">Bauer, Johann Gottfried</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_preferred_name() assert trans.json == {'preferred_name': 'Bauer, Johann Gottfried'}
def test_gnd_preferred_name_organisation(): """Test Preferred Name for Organisation 110 $a""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="110"> <subfield code="a">SBeurret Bailly Auktionen</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_preferred_name() assert trans.json == {'preferred_name': 'SBeurret Bailly Auktionen'}
def test_rero_preferred_name(): """Test Preferred Name for Person 100 $a""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="a">Brontë, Charlotte</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_preferred_name() assert trans.json == {'preferred_name': 'Brontë, Charlotte'}
def test_gnd_gender_male(): """Test gender 375 $a 1 = male, 2 = female, " " = not known.""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="375"> <subfield code="a">1</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_gender() assert trans.json == {'gender': 'male'}
def test_trans_rero_numeration(): """Test numeration for Person 100 $b""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="b">II</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_numeration() assert trans.json == {'numeration': 'II'}
def test_rero_variant_name(): """Test Variant Name for Person 400 $a""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="400"> <subfield code="a">Bell, Currer</subfield> </datafield> <datafield ind1=" " ind2=" " tag="400"> <subfield code="a">Brontë, Carlotta</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_variant_name() trans.trans_rero_variant_access_point() assert trans.json == { 'variant_access_point': ['Bell, Currer', 'Brontë, Carlotta'], 'variant_name': ['Bell, Currer', 'Brontë, Carlotta'] } xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="410"> <subfield code="a">Bell, Currer</subfield> </datafield> <datafield ind1=" " ind2=" " tag="410"> <subfield code="a">Brontë, Carlotta</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_variant_name() trans.trans_rero_variant_access_point() assert trans.json == { 'variant_access_point': ['Bell, Currer', 'Brontë, Carlotta'], 'variant_name': ['Bell, Currer', 'Brontë, Carlotta'] } xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="411"> <subfield code="a">Bell, Currer</subfield> </datafield> <datafield ind1=" " ind2=" " tag="411"> <subfield code="a">Brontë, Carlotta</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_variant_name() trans.trans_rero_variant_access_point()
def test_trans_idref_numeration(): """Test numeration for Person 200 $d""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="200"> <subfield code="d">II</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_numeration() assert trans.json == {'numeration': 'II'}
def test_gnd_country_associated(): """Test country_associated 043 $c codes ISO 3166-1.""" xml_part_to_add = """ <datafield tag="043" ind1=" " ind2=" "> <subfield code="c">XA-DE</subfield> </datafield> """ trans = trans_prep('gnd', xml_part_to_add) trans.trans_gnd_country_associated() assert trans.json == {'country_associated': 'gw'}
def test_idref_gender_unknown(): """Test gender 120 $a a = female, b = male, - = not known.""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="120"> <subfield code="a">-</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_gender() assert trans.json == {'gender': 'not known'}
def test_idref_country_associated(): """Test country_associated 102 $a codes ISO 3166-1.""" xml_part_to_add = """ <datafield tag="102" ind1=" " ind2=" "> <subfield code="a">DE</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_country_associated() assert trans.json == {'country_associated': 'gw'}
def test_idref_language(): """Test language of person 101 $a (language 3 characters) ISO 639-2""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="101"> <subfield code="a">fre</subfield> <subfield code="a">eng</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_language() assert trans.json == {'language': ['fre', 'eng']}
def test_idref_preferred_name_1(): """Test Preferred Name for Person 200 $ab""" xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="200"> <subfield code="a">Brontë</subfield> <subfield code="b">Charlotte</subfield> </datafield> """ trans = trans_prep('idref', xml_part_to_add) trans.trans_idref_preferred_name() assert trans.json == {'preferred_name': 'Brontë, Charlotte'}
def test_rero_birth_and_death_dates(): """Test date of birth 100 $d""" xml_part_to_add = "" trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_birth_and_death_dates() assert not trans.json xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="d">1816-1855</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_birth_and_death_dates() assert trans.json == {'date_of_birth': '1816', 'date_of_death': '1855'} xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="d">1816-</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_birth_and_death_dates() assert trans.json == {'date_of_birth': '1816'} xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="d">?-1855</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_birth_and_death_dates() assert trans.json == {'date_of_birth': '?', 'date_of_death': '1855'} xml_part_to_add = """ <datafield ind1=" " ind2=" " tag="100"> <subfield code="d">ca. 1800-1855</subfield> </datafield> """ trans = trans_prep('rero', xml_part_to_add) trans.trans_rero_birth_and_death_dates() assert trans.json == {'date_of_birth': 'ca. 1800', 'date_of_death': '1855'}