def test_set(): from dlx.marc import Bib bib = Bib() bib.set('245', 'a', 'Edited') assert bib.get_value('245', 'a') == 'Edited' bib.set('245', 'a', 'Repeated field', address=['+']) assert bib.get_values('245', 'a') == ['Edited', 'Repeated field'] bib.set('245', 'a', 'Repeated field edited', address=[1]) assert bib.get_value('245', 'a', address=[1, 0]) == 'Repeated field edited' bib.set('245', 'a', 'Repeated subfield', address=[1, '+']) assert bib.get_value('245', 'a', address=[1, 1]) == 'Repeated subfield' bib.set('651', 'a', 9) assert bib.get_xref('651', 'a') == 9 bib = Bib().set_values( ('245', 'a', 'yet another'), ('245', 'b', 'title'), ('500', 'a', 'desc'), ('500', 'a', 'desc', {'address': ['+']}), ) assert bib.get_values('245', 'a', 'b') == ['yet another', 'title'] assert bib.get_values('500', 'a') == ['desc', 'desc']
def test_get_value(bibs): from dlx.marc import Bib bib = Bib(bibs[0]) assert bib.get_value('000') == 'leader' assert bib.get_value('245', 'a') == 'This' assert bib.get_values('245', 'a', 'b') == ['This', 'is the'] assert bib.get_value('520', 'a', address=[1, 1]) == 'Repeated subfield' assert bib.get_values('520', 'a', place=1) == ['Another description', 'Repeated subfield'] assert bib.get_value('999', 'a') == '' assert bib.get_values('999', 'a') == [] assert bib.get_value('245', 'a') == bib.get('245', 'a') assert bib.get_values('520', 'a') == bib.gets('520', 'a')