-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More coverage, better naming, some basic QA
- Loading branch information
Adam Constabaris
committed
May 21, 2013
1 parent
22d486a
commit fbb4d30
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
|
||
import os,generate,json | ||
import generate | ||
|
||
|
||
# basic tests for quality, not some kind of guarantee that it | ||
# works. Run generate.py at least once successfully before | ||
# you try this, it will load up the cache | ||
|
||
#http://www.loc.gov/marc/bibliographic/concise/bd264.html | ||
#_marc_bibliographic_concise_bd264.html | ||
|
||
class FakeCacher(object): | ||
def fetch_text(self,url): | ||
return open(os.path.join(".cache","_marc_bibliographic_concise_bd264.html")).read() | ||
|
||
c = generate.Crawler(FakeCacher()) | ||
tag, data = c.get_field_data("whateva") | ||
|
||
assert '264' == tag, "test file contained unexpected tag %s" % tag | ||
assert 'indicators' in data, "264 tag didn't contain indicators" | ||
assert 'subfields' in data, "264 tag didn't contain subfields" | ||
assert len(data['subfields']) == 6, "Unexpected # of subfields (%d)" % len(data['subfields']) | ||
|
||
c = generate.Crawler() | ||
d = c.as_dict() | ||
for tag, data in d.iteritems(): | ||
if data['control_field']: | ||
assert 'indicators' not in data, "Control field %s contained indicators" % tag | ||
assert 'subfields' not in data, "Control field %s contained subfields"%tag | ||
else: | ||
assert 'indicators' in data, "Field %s had no indicators" % tag | ||
assert 'subfields' in data, "Field %s had no subfields" % tag | ||
for sf, d in data['subfields'].iteritems(): | ||
assert 'repeatable' in d | ||
assert 'definition' in d | ||
|
||
|
||
|
||
|