Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to prove MARC8 encoded import ability. #2705

Merged
merged 2 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"publishers": [
"Wells and Lilly",
"E. Bliss and E. White"
],
"pagination": "474 p.",
"subtitle": "duke of Otranto, minister of the General police of France",
"title": "The memoirs of Joseph Fouché",
"lccn": [
"16010652"
],
"notes": "\"When first published [1824] the Memoirs were accepted as Fouch\u00e9's own work, but owing to a suit instituted by his family they were later admitted to be that of Alphonse de Beauchamp ... But ... the work is undoubtedly based on Fouché's own notes and papers.\" -- Introduction to Memoirs relating to Fouché' ... Tr. from the French by E. Jules Méras. New York, 1912.",
"number_of_pages": 474,
"languages": [
"eng"
],
"subject_places": [
"France"
],
"lc_classifications": [
"DC198.F7 A3 1825a"
],
"publish_date": "1825",
"publish_country": "mau",
"by_statement": "Tr. from the French",
"authors": [
{
"death_date": "1820",
"name": "Fouché, Joseph duc d'Otrante",
"title": "duc d'Otrante",
"personal_name": "Fouché, Joseph",
"birth_date": "1759",
"entity_type": "person"
}
],
"publish_places": [
"Boston",
"New-York"
],
"subject_people": [
"Bonaparte family"
],
"oclc_numbers": [
"8406072"
],
"subjects": [
"History",
"Court and courtiers"
],
"contributions": [
"Beauchamp, Alph. de, 1767-1832, ed"
],
"subject_times": [
"1789-1815"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"publishers": [
"The Century co."
],
"pagination": "112 p.",
"title": "Merchants from Cathay",
"lccn": [
"13021274"
],
"number_of_pages": 112,
"languages": [
"eng"
],
"lc_classifications": [
"PS3503.E533 M4 1913"
],
"publish_date": "1913",
"publish_country": "nyu",
"authors": [
{
"birth_date": "1886",
"personal_name": "Benét, William Rose",
"death_date": "1950",
"name": "Benét, William Rose",
"entity_type": "person"
}
],
"by_statement": "by William Rose Benét",
"publish_places": [
"New York"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
01371cam 22002891 45000010009000000050017000090080041000260350021000679060045000880100017001330350019001500400023001690410013001920420012002050500023002171000049002402450117002892600072004063000019004785000374004976510032008716510033009036000022009367000042009589850030010009910051010301011506220050501153045.0820507s1825 mau 000 0aeng  9(DLC) 16010652 a7bcbccoclcrplduencipf19gy-gencatlg a 16010652  a(OCoLC)8406072 aDLCcScUdScUdDLC1 aenghfre apremarc00aDC198.F7bA3 1825a1 aFouchâe, Joseph,cduc d'Otrante,d1759-1820.04aThe memoirs of Joseph Fouchâe,bduke of Otranto, minister of the General police of France.cTr. from the French. aBoston,bWells and Lilly;aNew-York,bE. Bliss and E. White,c1825. a474 p.c23 cm. a"When first published [1824] the Memoirs were accepted as Fouchâe's own work, but owing to a suit instituted by his family they were later admitted to be that of Alphonse de Beauchamp ... But ... the work is undoubtedly based on Fouchâe's own notes and papers." -- Introduction to Memoirs relating to Fouchâe' ... Tr. from the French by E. Jules Mâeras. New York, 1912. 0aFrancexHistoryy1789-1815. 0aFrancexCourt and courtiers.30aBonaparte family.1 aBeauchamp, Alph. de,d1767-1832,eed. eOCLC REPLACEMENT cdsdistr bc-GenCollhDC198.F7iA3 1825atCopy 1wOCLCREP
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00618nam 22001932 4500001000800000005001700008008004100025035002100066906004500087010001700132040001900149050002500168100005700193245005200250260003900302300001900341985001400360991005000374682989000000000000000.0821227s1913 nyu 000 0 eng  9(DLC) 13021274 a0bcbccpremverduencipf19gy-gencatlg a 13021274  aDLCcCarPdDLC00aPS3503.E533bM4 19131 aBenâet, William Rose,d1886-1950. [from old catalog]10aMerchants from Cathay,cby William Rose Benâet. aNew York,bThe Century co.,c1913. a112 p.c23 cm. fce05genh bc-GenCollhPS3503.E533iM4 1913tCopy 1wPREM
1 change: 1 addition & 0 deletions openlibrary/catalog/marc/tests/test_marc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_fields(self, tag):
if tag == self.tag:
return [self.field]

# TODO: refactor to not use unittest
class TestMarcParse(unittest.TestCase):
def test_read_isbn(self):
data = [
Expand Down
8 changes: 7 additions & 1 deletion openlibrary/catalog/marc/tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
'engineercorpsofh00sher',
]

bin_samples = ['bpl_0486266893', 'flatlandromanceo00abbouoft_meta.mrc',
bin_samples = [
'merchantsfromcat00ben_meta.mrc', 'memoirsofjosephf00fouc_meta.mrc', # MARC8 encoded with e-acute
'bpl_0486266893', 'flatlandromanceo00abbouoft_meta.mrc',
'histoirereligieu05cr_meta.mrc', 'ithaca_college_75002321', 'lc_0444897283',
'lc_1416500308', 'ocm00400866', 'secretcodeofsucc00stjo_meta.mrc',
'uoft_4351105_1626', 'warofrebellionco1473unit_meta.mrc', 'wrapped_lines',
Expand Down Expand Up @@ -64,6 +66,10 @@ def test_binary(self, i):
rec = MarcBinary(data)
edition_marc_bin = read_edition(rec)
assert edition_marc_bin
if not os.path.exists(expect_filename):
# Missing test expectations file. Create a template from the input, but fail the current test.
simplejson.dump(edition_marc_bin, open(expect_filename, 'w'), indent=2)
assert False, 'Expectations file %s not found: template generated in %s. Please review and commit this file.' % (expect_filename, '/bin_expect')
j = simplejson.load(open(expect_filename))
assert j, "Unable to open test data: %s" % expect_filename
assert sorted(edition_marc_bin.keys()) == sorted(j.keys())
Expand Down