コード例 #1
0
ファイル: test_loader.py プロジェクト: hashimmm/iiifoo
def test_remote():
    urls = [
        # "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/manifest.json",
        # "http://manifests.ydc2.yale.edu/manifest/Admont23.json",
        #"http://oculus-dev.lib.harvard.edu/manifests/drs:5981093",
        #"http://iiif-dev.bodleian.ox.ac.uk/metadata/bib_germ_1485_d1/bib_germ_1485_d1.json",
        #"http://iiif-dev.bodleian.ox.ac.uk/metadata/ms_auct_t_inf_2_1/ms_auct_t_inf_2_1.json",
        #"http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b84473026/manifest.json",
        #"http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b84473026/manifest-ranges.json",
        #"http://demos.biblissima-condorcet.fr/mirador/data/add_ms_10289_edited_8v-9r.json",
        #"http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b8438674r/manifest.json",
        #"http://demos.biblissima-condorcet.fr/iiif/metadata/BVH/B410186201_LI03/manifest.json"
        #"http://sanddragon.bl.uk/IIIFMetadataService/add_ms_10289.json"
        #"http://sr-svx-93.unifr.ch/metadata/iiif/bbb-0218/manifest.json"
        # "http://www.shared-canvas.org/impl/demo1d/res/manifest.json"
    ]
    for u in urls:
        fh = urllib.urlopen(u)
        data = fh.read()
        fh.close()
        try:
            print "------"
            print u
            reader = ManifestReader(data)
            nmfst = reader.read()
            js = nmfst.toJSON()
        except Exception, e:
            print "   => %s: %s" % (e.__class__.__name__, e)
コード例 #2
0
ファイル: test_loader.py プロジェクト: hashimmm/iiifoo
def test_errors():
    top = '/%s/azaroth/Development/IIIF/sites/iiif.io/source/api/presentation/2.0/example/errors/collection.json' % HOMENAME
    fh = file(top)
    data = fh.read()
    fh.close()

    reader = ManifestReader(data)
    ncoll = reader.read()
    # And walk the manifests
    mfsts = []

    passes = 0

    for manifest in ncoll.manifests:
        print "manifest: %s" % manifest.id
        mfid = manifest.id
        fn = mfid.replace('http://iiif.io/',
                          '/%s/azaroth/Development/IIIF/sites/iiif.io/source/' % HOMENAME)
        fh = file(fn)
        data = fh.read()
        fh.close()
        try:
            passes += do_test(data, manifest.label, errorMap[mfid])
        except TestError, e:
            print "Failed for: %s" % manifest.label
        except:
コード例 #3
0
ファイル: test_loader.py プロジェクト: hashimmm/iiifoo
def test_fixtures():
    top = '/%s/azaroth/Development/IIIF/sites/iiif.io/source/api/presentation/2.0/example/fixtures/collection.json' % HOMENAME
    fh = file(top)
    data = fh.read()
    fh.close()

    reader = ManifestReader(data)
    ncoll = reader.read()
    # And walk the manifests
    mfsts = []
    for manifest in ncoll.manifests:
        mfid = manifest.id
        fn = mfid.replace('http://iiif.io/',
                          '/%s/azaroth/Development/IIIF/sites/iiif.io/source/' % HOMENAME)
        fh = file(fn)
        data = fh.read()
        fh.close()
        print "Manifest: %s" % mfid
        js = json.loads(data)
        reader = ManifestReader(data)
        nman = reader.read()
        js2 = nman.toJSON(top=True)
        if js != js2:
            print mfid
            data2 = nman.toString(compact=False)
            print "in: %s  out: %s" % (len(data), len(data2))
            print "- is in, + is out"
            for x in difflib.unified_diff(data.split('\n'), data2.split('\n')):
                print x
            raise TestError("Did not get everything!")
        # print "~~~~~~~~~"
        mfsts.append(nman)
コード例 #4
0
def read_file_and_validate(manifest, fails_only=False, warnings_only=False):
    json_data=open(manifest).read()

    data = json.loads(json_data)

    reader = ManifestReader(data, version='2.0')
    err = None
    try:
        mf = reader.read()
        mf.toJSON()
        # Passed!
        okay = 1
    except Exception, err:
        # Failed
        okay = 0
コード例 #5
0
ファイル: test_loader.py プロジェクト: hashimmm/iiifoo
def do_test(data, failmsg, excexp):
    debug_tests = 0
    reader = ManifestReader(data)
    if excexp == None:
        # Should pass
        try:
            what = reader.read()
            js = what.toJSON()
            print_warnings(reader)
            return 1
        except Exception, e:
            print_warnings(reader)
            if debug_tests:
                print "%s:  %s" % (e.__class__.__name__, e)
            raise TestError(failmsg)