Skip to content

Commit

Permalink
Split E101 to E101a and E101b, adding E101a test for repeated path
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeon committed Apr 21, 2021
1 parent b955d49 commit 8b07e7c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 7 additions & 1 deletion ocfl/data/validation-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,13 @@
"en": "OCFL Object %s inventory manifest content path %s must not begin or end with /."
}
},
"E101": {
"E101a": {
"params": ["where", "path"],
"description": {
"en": "OCFL Object %s inventory manifest content path %s is repeated."
}
},
"E101b": {
"params": ["where", "path"],
"description": {
"en": "OCFL Object %s inventory manifest content path %s used as both a directory and a file path."
Expand Down
9 changes: 6 additions & 3 deletions ocfl/inventory_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def validate_manifest(self, manifest):
# Check for conflicting content paths
for path in content_directories:
if path in content_paths:
self.error("E101", path=path)
self.error("E101b", path=path)

return (manifest_files, unnormalized_digests)

Expand Down Expand Up @@ -392,8 +392,11 @@ def check_content_path(self, path, content_paths, content_directories):
self.error("E099", path=path)
return
# Accumulate paths and directories
content_paths.add(path)
content_directories.add('/'.join([m.group(1)] + elements[0:-1]))
if path in content_paths:
self.error("E101a", path=path)
else:
content_paths.add(path)
content_directories.add('/'.join([m.group(1)] + elements[0:-1]))
else:
self.error("E042", path=path)

Expand Down
5 changes: 4 additions & 1 deletion tests/test_inventory_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_validate_manifest(self):
log.clear()
# Conflicting content paths
iv.validate_manifest({"067eca3f5b024afa00aeac03a3c42dc0042bf43cba56104037abea8b365c0cf672f0e0c14c91b82bbce6b1464e231ac285d630a82cd4d4a7b194bea04d4b2eb7": ['v1/content/a', 'v1/content/a/b']})
self.assertEqual(log.errors, ['E101'])
self.assertEqual(log.errors, ['E101b'])

def test_validate_fixity(self):
"""Test validate_fixity method."""
Expand Down Expand Up @@ -372,6 +372,9 @@ def test_check_content_path(self):
log.clear()
iv.check_content_path('v1/xyz/.', cp, cd)
self.assertEqual(log.errors, ['E099'])
log.clear()
iv.check_content_path('v1/xyz/anything', cp, cd)
self.assertEqual(log.errors, ['E101a'])
# Good cases
log.clear()
iv.check_content_path('v1/xyz/.secret/d', cp, cd)
Expand Down

0 comments on commit 8b07e7c

Please sign in to comment.