Esempio n. 1
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.assertEquals(book.title, expected_title,
                         "Expected title %s, got title %s"
                         % (expected_title, book.title))
Esempio n. 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))
Esempio n. 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.assertEquals(bin_marc, expected_bin_marc.read(),
                             "output of convert (line->bin) "
                             "didn't match example file")
Esempio n. 4
0
 def test_line_to_dict(self):
     """Also tests MARC.to_dict(marc)"""
     with open(example_path('line_marc.txt')) as line_marc:
         data = MARC.line_to_dict(line_marc.read())
         expected_title = "Wege aus einer kranken Gesellschaft"
         self.assertEqual(
             data['title'], expected_title,
             "Expected title %s, got %s" % (expected_title, data['title']))
Esempio n. 5
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")
Esempio n. 6
0
 def test_line_marc_to_book(self):
     with open(os.path.join(EXAMPLES_PATH, 'line_marc.txt')) as line_marc:
         book = MARC.line_to_book(line_marc.read())
         expected_title = "Wege aus einer kranken Gesellschaft"
         self.assertTrue(
             book.title == expected_title,
             "Expected title %s, got title %s" %
             (expected_title, book.title))
Esempio n. 7
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(six.next(reader))
         self.assertTrue(keyed_record.author.name,
                         "Failed to retrieve author name")
Esempio n. 8
0
 def test_line_to_dict(self):
     """Also tests MARC.to_dict(marc)"""
     with open(example_path('line_marc.txt')) as line_marc:
         data = MARC.line_to_dict(line_marc.read())
         expected_title = "Wege aus einer kranken Gesellschaft"
         self.assertEquals(data['title'], expected_title,
                         "Expected title %s, got %s"
                         % (expected_title, data['title']))
Esempio n. 9
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")
Esempio n. 10
0
 def test_unicode_line_marc_to_book(self):
     line_marc_file = example_path('line_marc_unicode.txt')
     with open(line_marc_file) as line_marc:
         book = MARC.line_to_book(line_marc.read())
         expected_author = u'ƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƘƙƚƛƜƝƞƟƠơ'
         expected_title = u'ΛΦϞЌЍЖ⁁⅀∰   ﬢﬡ-中英字典こんにちはß'
         self.assertEquals(book.primary_author.name, expected_author,
                         "Expected author %s, got author %s" % \
                         (expected_author, book.primary_author.name))
         self.assertEquals(book.primary_author.name, expected_author,
                         "Expected title %s, got title %s" % \
                         (expected_title, book.title))
Esempio n. 11
0
 def test_unicode_line_marc_to_book(self):
     line_marc_file = example_path('line_marc_unicode.txt')
     with open(line_marc_file) as line_marc:
         book = MARC.line_to_book(line_marc.read())
         expected_author = u'ƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƘƙƚƛƜƝƞƟƠơ'
         expected_title = u'ΛΦϞЌЍЖ⁁⅀∰   ﬢﬡ-中英字典こんにちはß'
         self.assertEquals(book.primary_author.name, expected_author,
                         "Expected author %s, got author %s" % \
                         (expected_author, book.primary_author.name))
         self.assertEquals(book.primary_author.name, expected_author,
                         "Expected title %s, got title %s" % \
                         (expected_title, book.title))
Esempio n. 12
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.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")
Esempio n. 13
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")