test zip validator
+from os import unlink
+from os.path import join
+
from tests.base import TestCase, main, assets # pylint: disable=import-error,no-name-in-module
-from ocrd_validators import OcrdZipValidator
+from ocrd_validators import OcrdZipValidator
from ocrd.workspace import Workspace
from ocrd.workspace_bagger import WorkspaceBagger
from ocrd.resolver import Resolver
@@ -25,5 +28,14 @@ class TestOcrdZipValidator(TestCase):
self.assertEqual(report.is_valid, True)
print(report)
+ def test_fail_validation_unzipped_extra_files(self):
+ validator = OcrdZipValidator(self.resolver, assets.path_to('kant_aufklaerung_1784'))
+ extrapath = join(assets.path_to('kant_aufklaerung_1784'), 'data', 'EXTRA')
+ with open(extrapath, 'w') as f:
+ f.write('FAIL')
+ with self.assertRaisesRegex(Exception, "Payload-Oxum validation failed"):
+ validator.validate(skip_unzip=True)
+ unlink(extrapath)
+
if __name__ == '__main__':
main()
