Skip to content

Commit

Permalink
Testing for Correct rights URIs
Browse files Browse the repository at this point in the history
Fixes #79
  • Loading branch information
glenrobson committed Dec 4, 2019
1 parent cffa9e7 commit f2b9b5c
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fixtures/3/full_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"behavior": [ "paged" ],
"navDate": "1856-01-01T00:00:00Z",

"rights": "https://creativecommons.org/licenses/by/4.0/",
"rights": "http://creativecommons.org/licenses/by/4.0",
"requiredStatement": {
"label": { "en": [ "Attribution" ] },
"value": { "en": [ "Provided by Example Organization" ] }
Expand Down
101 changes: 98 additions & 3 deletions schema/iiif_3_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,104 @@
}
},
"rights": {
"type": "string",
"format": "uri",
"pattern": "^http.*$"
"title": "Rights URI isn't from either Creative Commons or Rights statements.org. Both require http links.",
"oneOf": [
{
"type": "string",
"format": "uri",
"pattern": "http://creativecommons.org/licenses/by/4.0"
},
{
"type": "string",
"format": "uri",
"pattern": "http://creativecommons.org/licenses/by-sa/4.0"
},
{
"type": "string",
"format": "uri",
"pattern": "http://creativecommons.org/licenses/by-nd/4.0"
},
{
"type": "string",
"format": "uri",
"pattern": "http://creativecommons.org/licenses/by-nc/4.0"
},
{
"type": "string",
"format": "uri",
"pattern": "http://creativecommons.org/licenses/by-nc-sa/4.0"
},
{
"type": "string",
"format": "uri",
"pattern": "http://creativecommons.org/licenses/by-nc-nd/4.0"
},
{
"type": "string",
"format": "uri",
"pattern": "http://creativecommons.org/publicdomain/mark/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/InC/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/InC-OW-EU/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/InC-EDU/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/InC-NC/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/InC-RUU/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/NoC-CR/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/NoC-NC/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/NoC-OKLR/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/NoC-US/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/CNE/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/UND/1.0/"
},
{
"type": "string",
"format": "uri",
"pattern": "http://rightsstatements.org/vocab/NKC/1.0/"
}
]
},
"navDate": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schema/schemavalidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@ def validate(data, version, url):
print('Validation Failed')
errorCount = 1
for err in errors:
error += 'Error {} of {}.\n Message: {}'.format(errorCount, len(errors), err.message)
detail = ''
if 'title' in err.schema:
detail = err.schema['title']
# print (' Test message: {}'.format(detail))
description = ''
if 'description' in err.schema:
description = err.schema['description']
# print (' Test description: {}'.format(description))
#print('\n Path for error: {}'.format(printPath(err.path, err.message)))
detail += err.schema['description']
context = err.instance
#print (json.dumps(err.instance, indent=4))
if isinstance(context, dict):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ def printValidationerror(self, filename, errors):
errorCount = 1
for err in errors:
print(err['title'])
if 'description' in err:
print (' Test description: {}'.format(err['description']))
print(err['detail'])
print('\n Path for error: {}'.format(err['path']))
print('\n Context: {}'.format(err['context']))
errorCount += 1
Expand Down

0 comments on commit f2b9b5c

Please sign in to comment.