Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_no_mets_url(self):
with self.assertRaisesRegex(Exception, 'pass mets_url to create a workspace'):
run_processor(DummyProcessor, resolver=self.resolver)
def test_run_agent(self):
no_agents_before = len(self.workspace.mets.agents)
run_processor(DummyProcessor, ocrd_tool=DUMMY_TOOL, workspace=self.workspace)
self.assertEqual(len(self.workspace.mets.agents), no_agents_before + 1, 'one more agent')
# print(self.workspace.mets.agents[no_agents_before])
def test_run_cli(self):
with TemporaryDirectory() as tempdir:
run_processor(DummyProcessor, ocrd_tool=DUMMY_TOOL, workspace=self.workspace)
run_cli(
'echo',
mets_url=assets.url_of('SBB0000F29300010000/data/mets.xml'),
resolver=Resolver(),
workspace=None,
page_id='page1',
log_level='DEBUG',
input_file_grp='INPUT',
output_file_grp='OUTPUT',
parameter='/path/to/param.json',
working_dir=tempdir
)
run_cli(
'echo',
mets_url=assets.url_of('SBB0000F29300010000/data/mets.xml'),
resolver=Resolver(),
def test_no_resolver(self):
with self.assertRaisesRegex(Exception, 'pass a resolver to create a workspace'):
run_processor(DummyProcessor)
def test_with_mets_url_input_files(self):
processor = run_processor(DummyProcessor, resolver=self.resolver, mets_url=assets.url_of('SBB0000F29300010000/data/mets.xml'))
self.assertEqual(len(processor.input_files), 35)
def test_parameter(self):
with TemporaryDirectory() as tempdir:
jsonpath = join(tempdir, 'params.json')
with open(jsonpath, 'w') as f:
f.write('{"baz": "quux"}')
with open(jsonpath, 'r') as f:
processor = run_processor(
DummyProcessor,
parameter=json.load(f),
resolver=self.resolver,
mets_url=assets.url_of('SBB0000F29300010000/data/mets.xml')
)
self.assertEqual(len(processor.input_files), 35)