def test_field_get_value(bibs): from dlx.marc import Bib bib = Bib(bibs[0]) field = bib.get_field('245') assert field.get_value('a') == 'This' assert field.get_values('a', 'b') == ['This', 'is the']
def test_get_field(bibs): from dlx.marc import Bib, Field, Controlfield, Datafield bib = Bib(bibs[0]) assert isinstance(bib.get_field('000'), Controlfield) assert isinstance(bib.get_field('245'), Datafield) assert bib.get_field('245').tag == '245' fields = bib.get_fields('245', '520') for field in fields: assert isinstance(field, Field) bib = Bib() for tag in ('400', '100', '500', '300', '200'): bib.set(tag, 'a', 'test') assert [field.tag for field in bib.get_fields()] == ['100', '200', '300', '400', '500']