Example #1
0
 def test_physicaldescription(self):
     record = Record()
     pd1 = '=300  \\$a1 photographic print :$bgelatin silver ;$c10 x 56 in.'
     pd2 = '=300  \\$aFOO$bBAR$cBAZ'
     pdlist = [pd1, pd2]
     self.assertEqual(record.physicaldescription(), [])
     record.add_field(Field('300', ['\\', ''],
         subfields=['a', '1 photographic print :',
                    'b', 'gelatin silver ;',
                    'c', '10 x 56 in.']))
     record.add_field(Field('300', ['\\', ''],
         subfields=['a', 'FOO',
                    'b', 'BAR',
                    'c', 'BAZ']))
     self.assertEqual(len(record.physicaldescription()), 2)
     self.assertEqual(record.physicaldescription()[0].__str__(), pd1)
     self.assertEqual(record.physicaldescription()[1].__str__(), pd2)
     rpdlist = [rpd.__str__() for rpd in record.physicaldescription()]
     self.assertEqual(pdlist, rpdlist)
Example #2
0
 def test_subjects(self):
     record = Record()
     subject1 = '=630  0\\$aTosefta.$lEnglish.$f1977.'
     subject2 = '=600  10$aLe Peu, Pepe.'
     shlist = [subject1, subject2]
     self.assertEqual(record.subjects(), [])
     record.add_field(
         Field('630', [0, ' '],
               subfields=['a', "Tosefta.", 'l', "English.", 'f', "1977."]))
     record.add_field(
         Field('730', [0, ' '],
               subfields=['a', "Tosefta.", 'l', "English.", 'f', "1977."]))
     record.add_field(Field('600', [1, 0], subfields=['a',
                                                      "Le Peu, Pepe."]))
     self.assertEqual(len(record.subjects()), 2)
     self.assertEqual(record.subjects()[0].__str__(), subject1)
     self.assertEqual(record.subjects()[1].__str__(), subject2)
     rshlist = [rsh.__str__() for rsh in record.subjects()]
     self.assertEqual(shlist, rshlist)
Example #3
0
 def test_added_entries(self):
     record = Record()
     ae1 = "=730  0\\$aTosefta.$lEnglish.$f1977."
     ae2 = "=700  10$aLe Peu, Pepe."
     aelist = [ae1, ae2]
     self.assertEqual(record.addedentries(), [])
     record.add_field(
         Field(
             "730",
             [0, " "],
             subfields=["a", "Tosefta.", "l", "English.", "f", "1977."],
         ))
     record.add_field(Field("700", [1, 0], subfields=["a",
                                                      "Le Peu, Pepe."]))
     record.add_field(
         Field("245", [0, 0], subfields=["a", "Le Peu's Tosefa."]))
     self.assertEqual(len(record.addedentries()), 2)
     self.assertEqual(record.addedentries()[0].__str__(), ae1)
     self.assertEqual(record.addedentries()[1].__str__(), ae2)
     raelist = [rae.__str__() for rae in record.addedentries()]
     self.assertEqual(aelist, raelist)
Example #4
0
 def test_bad_base_address(self):
     record = Record()
     self.assertRaises(BaseAddressInvalid, record.decode_marc,
                       b'00695cam  2200241Ia 45x00')
Example #5
0
 def test_bad_leader(self):
     record = Record()
     self.assertRaises(RecordLeaderInvalid, record.decode_marc, b'foo')
Example #6
0
 def test_field_not_found(self):
     record = Record()
     self.assertEqual(len(record.fields), 0)
Example #7
0
 def test_as_marc_consistency(self):
     record = Record()
     leadertype = type(record.leader)
     record.as_marc()
     self.assertEqual(leadertype, type(record.leader))
Example #8
0
 def test_notes(self):
     record = Record()
     self.assertEqual(record.notes(), [])
     record.add_field(Field('500', [' ', ' '],
         subfields=['a', "Recast in bronze from artist's plaster original of 1903."]))
     self.assertEqual(record.notes()[0].format_field(), "Recast in bronze from artist's plaster original of 1903.")
Example #9
0
 def test_issn(self):
     record = Record()
     self.assertEqual(record.issn(), None)
     record.add_field(Field(tag="022", indicators=["0", ""], subfields=["a", "0395-2037"]))
     self.assertEqual(record.issn(), '0395-2037')
Example #10
0
 def test_bad_leader(self):
     record = Record()
     self.failUnlessRaises(RecordLeaderInvalid, record.decode_marc, 'foo')
Example #11
0
 def test_pub_date(self):
     record = Record()
     self.assertEqual(record.pub_date(), None)
     record.add_field(Field('269', [' ', ' '], subfields=['a', '20170123']))
     self.assertEqual(record.pub_date(), '20170123')