diff --git a/ocfl/data/validation-errors.json b/ocfl/data/validation-errors.json index 41b2d11..eafab21 100644 --- a/ocfl/data/validation-errors.json +++ b/ocfl/data/validation-errors.json @@ -136,16 +136,22 @@ "en": "OCFL Object %s manifest does not include files listed in previous version manifests (%s)" } }, + "E024": { + "params": ["where", "path"], + "description": { + "en": "OCFL Object version %s content directory includes empty path %s" + } + }, "E025a": { - "params": ["where", "digest", "algorithm"], + "params": ["where", "digest_algorithm"], "description": { - "en": "OCFL Object %s inventory manifest block includes a digest (%s) that doesn't have the correct form for the %s algorithm" + "en": "OCFL Object %s inventory `digestAlgorithm` attribute not an allowed digest type (got '%s')" } }, - "E024": { - "params": ["where", "path"], + "E025b": { + "params": ["where", "digest", "algorithm"], "description": { - "en": "OCFL Object version %s content directory includes empty path %s" + "en": "OCFL Object %s inventory manifest block includes a digest (%s) that doesn't have the correct form for the %s algorithm" } }, "E026a": { @@ -214,12 +220,6 @@ "en": "OCFL Object %s inventory `type` attribute has an unsupported specification version number (%s), will proceed as if using version %s" } }, - "E039": { - "params": ["where", "digest_algorithm"], - "description": { - "en": "OCFL Object %s inventory `digestAlgorithm` attribute not an allowed value (got '%s')" - } - }, "E040": { "params": ["where", "got", "expected"], "description": { diff --git a/ocfl/inventory_validator.py b/ocfl/inventory_validator.py index 2e5f5df..e5122eb 100644 --- a/ocfl/inventory_validator.py +++ b/ocfl/inventory_validator.py @@ -115,7 +115,8 @@ def validate(self, inventory, force_spec_version=None): self.warning("W004") self.digest_algorithm = inventory['digestAlgorithm'] else: - self.error("E039", digest_algorithm=inventory['digestAlgorithm']) + self.error("E025a", digest_algorithm=inventory['digestAlgorithm']) + return if 'contentDirectory' in inventory: # Careful only to set self.content_directory if value is safe cd = inventory['contentDirectory'] @@ -180,7 +181,7 @@ def validate_manifest(self, manifest): for digest in manifest: m = re.match(self.digest_regex(), digest) if not m: - self.error('E025a', digest=digest, algorithm=self.digest_algorithm) # wrong form of digest + self.error('E025b', digest=digest, algorithm=self.digest_algorithm) # wrong form of digest elif not isinstance(manifest[digest], list): self.error('E092', digest=digest) # must have path list value else: diff --git a/tests/test_inventory_validator.py b/tests/test_inventory_validator.py index cacd1da..b1595cd 100644 --- a/tests/test_inventory_validator.py +++ b/tests/test_inventory_validator.py @@ -69,7 +69,7 @@ def test_validate(self): log.clear() iv.validate({"id": "like:uri", "type": "wrong type", "digestAlgorithm": "my_digest"}) self.assertIn('E038b', log.errors) - self.assertIn('E039', log.errors) + self.assertIn('E025a', log.errors) log.clear() iv.validate({"id": "like:uri", "type": "wrong type", "digestAlgorithm": "my_digest"}) self.assertIn('E038b', log.errors) @@ -79,7 +79,7 @@ def test_validate(self): iv = InventoryValidator(log=log, lax_digests=True) log.clear() iv.validate({"id": "like:uri", "type": "wrong type", "digestAlgorithm": "my_digest"}) - self.assertNotIn('E039', log.errors) + self.assertNotIn('E025a', log.errors) self.assertEqual(iv.digest_algorithm, "my_digest") iv = InventoryValidator(log=log) log.clear() @@ -100,7 +100,7 @@ def test_validate_manifest(self): self.assertIn('E041c', log.errors) log.clear() self.assertEqual(iv.validate_manifest({"xxx": []}), ({}, [], set())) - self.assertIn('E025a', log.errors) + self.assertIn('E025b', log.errors) log.clear() self.assertEqual(iv.validate_manifest({"067eca3f5b024afa00aeac03a3c42dc0042bf43cba56104037abea8b365c0cf672f0e0c14c91b82bbce6b1464e231ac285d630a82cd4d4a7b194bea04d4b2eb7": "not an array"}), ({}, [], set())) self.assertIn('E092', log.errors)