def test_convert_line_to_bin(self):
     with open(example_path('line_marc.txt')) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         with open(example_path('bin_marc.mrc'), 'rb') as expected_bin_marc:
             self.assertEquals(bin_marc, expected_bin_marc.read(),
                             "output of convert (line->bin) "
                             "didn't match example file")
示例#2
0
 def test_bin_marc_to_book(self):
     with open(os.path.join(EXAMPLES_PATH, 'line_marc.txt')) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         book = MARC.to_book(bin_marc)
         expected_title = "Wege aus einer kranken Gesellschaft"
         self.assertEqual(
             book.title, expected_title, "Expected title %s, got title %s" %
             (expected_title, book.title))
示例#3
0
 def test_convert_line_to_bin(self):
     with open(example_path('line_marc.txt')) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         with open(example_path('bin_marc.mrc'), 'rb') as expected_bin_marc:
             self.assertEqual(
                 bin_marc, expected_bin_marc.read(),
                 "output of convert (line->bin) "
                 "didn't match example file")
 def test_MARCRecord(self):
     with open(os.path.join(EXAMPLES_PATH, 'line_marc.txt')) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         reader = pymarc.MARCReader(bin_marc, hide_utf8_warnings=True,
                                    force_utf8=True, utf8_handling='ignore')
         keyed_record = MARCRecord(six.next(reader))
         self.assertTrue(keyed_record.author.name,
                         "Failed to retrieve author name")
 def test_bin_marc_to_book(self):
     with open(os.path.join(EXAMPLES_PATH, 'line_marc.txt')) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         book = MARC.to_book(bin_marc)
         expected_title = "Wege aus einer kranken Gesellschaft"
         self.assertEquals(book.title, expected_title,
                         "Expected title %s, got title %s"
                         % (expected_title, book.title))
示例#6
0
 def test_MARCRecord(self):
     with open(os.path.join(EXAMPLES_PATH, 'line_marc.txt')) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         reader = pymarc.MARCReader(bin_marc,
                                    hide_utf8_warnings=True,
                                    force_utf8=True,
                                    utf8_handling='ignore')
         keyed_record = MARCRecord(next(reader))
         self.assertTrue(keyed_record.author.name,
                         "Failed to retrieve author name")
 def test_line_to_bin_unicode(self):
     line_marc_file = example_path('line_marc_unicode.txt')
     bin_marc_file = example_path('bin_marc_unicode.mrc')
     with open(line_marc_file) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         with open(bin_marc_file, 'rb') as expected_bin_marc:
             self.assertEquals(bin_marc, expected_bin_marc.read(),
                             "Binary MARC didn't match expected " \
                             "unicode content")
             marcs = pymarc.MARCReader(bin_marc, hide_utf8_warnings=True,
                                       force_utf8=True, utf8_handling='ignore')
             marc = six.next(marcs)
             self.assertEquals(marc.author(),
                             u'ƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƘƙƚƛƜƝƞƟƠơ '\
                             '1900-1980 Verfasser (DE-588)118536389 aut',
                             "Line MARC title didn't match pymarc title")
示例#8
0
 def test_line_to_bin_unicode(self):
     line_marc_file = example_path('line_marc_unicode.txt')
     bin_marc_file = example_path('bin_marc_unicode.mrc')
     with open(line_marc_file) as line_marc:
         bin_marc = MARC.convert(line_marc.read())
         with open(bin_marc_file, 'rb') as expected_bin_marc:
             self.assertEqual(bin_marc, expected_bin_marc.read(),
                             "Binary MARC didn't match expected " \
                             "unicode content")
             marcs = pymarc.MARCReader(bin_marc,
                                       hide_utf8_warnings=True,
                                       force_utf8=True,
                                       utf8_handling='ignore')
             marc = next(marcs)
             self.assertEqual(marc.author(),
                             'ƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƘƙƚƛƜƝƞƟƠơ '\
                             '1900-1980 Verfasser (DE-588)118536389 aut',
                             "Line MARC title didn't match pymarc title")