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_xref(db, bibs): from dlx.marc import Bib bib = Bib(bibs[0]) assert bib.get_xref('650', 'a') == 1 bib.set('710', 'a', 3, address='+') assert bib.get_xrefs('710') == [2,3]