Skip to content

Commit

Permalink
More coverage, better naming, some basic QA
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Constabaris committed May 21, 2013
1 parent 22d486a commit fbb4d30
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.cache
41 changes: 41 additions & 0 deletions check.py
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




0 comments on commit fbb4d30

Please sign in to comment.