Skip to content

Commit

Permalink
tests.processor: check profile log
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Feb 17, 2025
1 parent 7bc2f4c commit ee24a3e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/processor/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ def test_params_missing_required(self):
run_processor(DummyProcessorWithRequiredParameters,
workspace=self.workspace, input_file_grp="OCR-D-IMG")
proc.parameter = {'i-am-required': 'foo'}
proc.input_file_grp = "OCR-D-IMG"
proc.output_file_grp = "OCR-D-OUT"
proc.page_id = []
proc.process_workspace(self.workspace)
run_processor(DummyProcessorWithRequiredParameters,
workspace=self.workspace,
input_file_grp="OCR-D-IMG",
output_file_grp="OCR-D-OUT",
parameter={'i-am-required': 'foo'})

def test_params_preset_resolve(self):
with pushd_popd(tempdir=True) as tempdir:
Expand Down Expand Up @@ -433,6 +442,31 @@ def ocrd_tool(self):
r = self.capture_out_err()
assert 'ERROR ocrd.processor.base - Found no file for page phys_0001 in file group GRP1' in r.err

@pytest.fixture
def workspace_sbb():
initLogging()
with copy_of_directory(assets.path_to('SBB0000F29300010000/data')) as workdir:
with pushd_popd(workdir):
resolver = Resolver()
workspace = resolver.workspace_from_url('mets.xml')
yield workspace
disableLogging()

def test_run_output_logging(workspace_sbb, caplog):
caplog.set_level(10)
def only_profile(logrec):
return logrec.name == 'ocrd.process.profile'
with caplog.filtering(only_profile):
proc = run_processor(DummyProcessorWithRequiredParameters,
workspace=workspace_sbb,
input_file_grp="OCR-D-IMG",
output_file_grp="OCR-D-OUT",
parameter={'i-am-required': 'foo'})
assert len(caplog.records) == 1
#assert isinstance(proc.parameter, dict)
msg = caplog.records[0].message
assert msg.startswith("Executing processor 'ocrd-test' took")

def test_run_output_metsserver(start_mets_server):
mets_server_url, ws = start_mets_server
assert len(ws.mets.find_all_files(fileGrp="OCR-D-OUT")) == 0
Expand Down

0 comments on commit ee24a3e

Please sign in to comment.