def test_960_items_nonrepeatable_subfields(self): b = Record() b.add_field( Field(tag='960', indicators=[' ', ' '], subfields=[ 'i', 'TEST', 'i', 'TEST', 'l', 'TEST', 'l', 'TEST', 'p', '9.99', 'p', '9.99', 'q', 'TEST', 'q', 'TEST', 'o', 'TEST', 'o', 'TEST', 't', 'TEST', 't', 'TEST', 'r', 'TEST', 'r', 'TEST', 's', 'TEST', 's', 'TEST', 'v', 'TEST', 'v', 'TEST', 'n', 'TEST', 'n', 'TEST', 'v', 'TEST', 'v', 'TEST' ])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertIn('"i" subfield is not repeatable.', report) self.assertIn('"l" subfield is not repeatable.', report) self.assertIn('"p" subfield is not repeatable.', report) self.assertIn('"q" subfield is not repeatable.', report) self.assertIn('"o" subfield is not repeatable.', report) self.assertIn('"t" subfield is not repeatable.', report) self.assertIn('"r" subfield is not repeatable.', report) self.assertIn('"s" subfield is not repeatable.', report) self.assertIn('"v" subfield is not repeatable.', report) self.assertIn('"n" subfield is not repeatable.', report)
def test_write_marc21(self): bibs.write_marc21(self.fh_out, self.marc_bib) contents = open(self.fh_out).read() self.assertEqual( contents, "00266nam a2200085u 4500001002400000245001500024949004700039949004700086960004700133\x1e0001-test-control_field\x1e00\x1faTest title\x1e 1\x1fi33333818132462\x1flfea0f\x1fp9.99\x1ft102\x1fvAMALIVRE\x1e 1\x1fi33333818132464\x1flfea0f\x1fp9.99\x1ft102\x1fvAMALIVRE\x1e \x1fi33333818132466\x1flfea0f\x1fp9.99\x1ft102\x1fvAMALIVRE\x1e\x1d", )
def test_960_items_correct_price_format(self): b = Record() b.add_field( Field(tag='960', indicators=[' ', '1'], subfields=['p', '9.99'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertNotIn('"p" subfield has incorrect price format.', report)
def test_960_items_incorrect_format(self): b = Record() b.add_field( Field(tag='960', indicators=[' ', ' '], subfields=['r', 'z'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertIn('"r" subfield has incorrect value.', report)
def test_949_items_stat_code_incorrect(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=['t', '600'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertIn('"t" subfield has incorrect value.', report)
def test_949_subfield_a_mandatory(self): b = Record() b.add_field(Field(tag='949', indicators=[' ', ' '], subfields=[])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertIn('"a" subfield is mandatory.', report)
def test_949_items_empty_price_subfield(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=['p', ''])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertIn('"p" subfield has incorrect price format.', report)
def test_960_items_mandatory(self): b = Record() b.add_field( Field(tag='960', indicators=[' ', '1'], subfields=['a', 'TEST'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertIn('"960 " mandatory tag not found.', report)
def test_960_items_incorrect_location(self): b = Record() b.add_field( Field(tag='960', indicators=[' ', ' '], subfields=['l', 'mma0l'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertIn('"l" subfield has incorrect location code.', report)
def test_949_items_barcode_not_digits(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=['i', 'TEST'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertIn('"i" subfield has incorrect barcode.', report)
def test_947_incorrect_subfield_a_value(self): b = Record() b.add_field( Field(tag='947', indicators=[' ', ' '], subfields=['a', 'TEST'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertIn('"a" subfield has incorrect value', report)
def test_091_no_subfield_a(self): b = Record() b.add_field( Field(tag='099', indicators=[' ', ' '], subfields=['p', 'TEST'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertIn('"a" subfield is mandatory.', report)
def test_949_subfield_a_incorrect_value(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', ' '], subfields=['a', 'b2=a;'])) # missing * in the begining bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertIn('"a" subfield has incorrect value', report)
def test_960_items_good_barcode(self): b = Record() b.add_field( Field(tag='960', indicators=[' ', '1'], subfields=['i', '34444987954328'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertNotIn('"i" subfield has incorrect barcode.', report)
def test_960_repeatable_diff_indicators(self): b = Record() b.add_field( Field(tag='960', indicators=[' ', ' '], subfields=['a', 'TEST'])) b.add_field( Field(tag='960', indicators=[' ', '1'], subfields=['a', 'TEST'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertNotIn('"960 1" is not repeatable', report)
def test_947_nonrepeatable_subfield_a(self): b = Record() b.add_field( Field(tag='947', indicators=[' ', ' '], subfields=['a', 'TEST', 'a', 'TEST1'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertIn('"a" subfield is not repeatable.', report)
def test_949_items_repeatable(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=['a', 'TEST'])) b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=['a', 'TEST2'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertNotIn('"949 1" is not repeatable.', report)
def test_091_not_repeatable(self): b = Record() b.add_field( Field(tag='099', indicators=[' ', ' '], subfields=['a', 'TEST'])) b.add_field( Field(tag='0099', indicators=[' ', ' '], subfields=['a', 'TEST2'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'bpl', ['specs_test.mrc'], self.bcl) self.assertFalse(passed) self.assertIn('"099 " is not repeatable', report)
def test_949_items_mandatory_subfields(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=['a', 'TEST'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertIn('"i" subfield is mandatory.', report) self.assertIn('"l" subfield is mandatory.', report) self.assertIn('"p" subfield is mandatory.', report) self.assertIn('"t" subfield is mandatory.', report) self.assertIn('"v" subfield is mandatory.', report)
def test_949_items_location_mandatory(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=[ 'i', '33333700904853', 'p', '4.99', 't', '211', 'v', 'BTSERIES' ])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertIn('"l" subfield is mandatory.', report)
def test_dvd_case1(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=[ 'i', '33333306093499', 'l', 'mya0v', 'p', '24.99', 't', '111', 'v', 'Midwest', 'n', 'o24643440', 'q', '10001' ])) b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=[ 'i', '33333306093481', 'l', 'bta0v', 'p', '24.99', 't', '111', 'v', 'Midwest', 'n', 'o24643440', 'q', '10001' ])) b.add_field( Field(tag='901', indicators=[' ', ' '], subfields=['a', 'Midwest'])) b.add_field( Field(tag='949', indicators=[' ', ' '], subfields=['a', '*b2=v;'])) bibs.write_marc21('specs_test.mrc', b) b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=[ 'i', '33333306093457', 'l', 'mya0v', 'p', '14.99', 't', '206', 'v', 'Midwest', 'n', 'o24643282', 'q', '10001' ])) b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=[ 'i', '33333306093432', 'l', 'bca0v', 'p', '14.99', 't', '206', 'v', 'Midwest', 'n', 'o24643282', 'q', '10001' ])) b.add_field( Field(tag='901', indicators=[' ', ' '], subfields=['a', 'Midwest'])) b.add_field( Field(tag='949', indicators=[' ', ' '], subfields=['a', '*b2=v;'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertTrue(passed)
def test_091_subfields(self): b = Record() b.add_field( Field(tag='091', indicators=[' ', ' '], subfields=['p', 'TEST', 'p', 'TEST', 'c', 'TEST'])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertIn( '"091": tag occurance 1:\n\t"p" subfield is not repeatable.', report) self.assertIn('"a" subfield is mandatory.', report)
def test_949_items_nonrepeatable_subfields(self): b = Record() b.add_field( Field(tag='949', indicators=[' ', '1'], subfields=[ 'i', 'TEST', 'i', 'TEST', 'l', 'TEST', 'l', 'TEST', 'p', '9.99', 'p', '9.99', 't', 'TEST', 't', 'TEST', 'o', 'TEST', 'o', 'TEST', 'u', 'TEST', 'u', 'TEST', 'm', 'TEST', 'm', 'TEST', 'v', 'TEST', 'v', 'TEST' ])) bibs.write_marc21('specs_test.mrc', b) passed, report = local_specs.local_specs_validation( 'nypl', ['specs_test.mrc'], self.ncl) self.assertFalse(passed) self.assertIn('"i" subfield is not repeatable.', report) self.assertIn('"l" subfield is not repeatable.', report) self.assertIn('"p" subfield is not repeatable.', report) self.assertIn('"t" subfield is not repeatable.', report) self.assertIn('"o" subfield is not repeatable.', report)
def test_barcodes_duplicates_in_two_bpl_files(self): bib = Record() bib.leader = '00000nam a2200000u 4500' tags = [] tags.append(Field(tag='001', data='ocm00000003')) tags.append( Field(tag='245', indicators=['0', '0'], subfields=['a', 'Test title 1'])) tags.append( Field(tag='960', indicators=[' ', ' '], subfields=[ 'i', '34444849044539', 'l', '14afc', 'p', '14.95', 't', '100', 'v', 'BTURBN' ])) for tag in tags: bib.add_ordered_field(tag) bibs.write_marc21(self.fh1, bib) bib = Record() bib.leader = '00000nam a2200000u 4500' tags = [] tags.append(Field(tag='001', data='ocm00000001')) tags.append( Field(tag='245', indicators=['0', '0'], subfields=['a', 'Test title 1'])) tags.append( Field(tag='960', indicators=[' ', ' '], subfields=[ 'i', '34444849044538', 'l', '14afc', 'p', '14.95', 't', '100', 'v', 'BTURBN' ])) for tag in tags: bib.add_ordered_field(tag) bibs.write_marc21(self.fh1, bib) bib = Record() bib.leader = '00000nam a2200000u 4500' tags = [] tags.append(Field(tag='001', data='ocm00000001')) tags.append( Field(tag='245', indicators=['0', '0'], subfields=['a', 'Test title 1'])) tags.append( Field(tag='960', indicators=[' ', ' '], subfields=[ 'i', '34444849044538', 'l', '14afc', 'p', '14.95', 't', '100', 'v', 'BTURBN' ])) for tag in tags: bib.add_ordered_field(tag) bibs.write_marc21(self.fh2, bib) self.assertEqual( default.barcode_duplicates([self.fh1, self.fh2], 'bpl'), { u'34444849044538': [('barcode1_dup_test.mrc', 2), ('barcode2_dup_test.mrc', 1)] })