mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-11-10 06:34:11 +01:00
refactor cli tests
This commit is contained in:
parent
ef999c8f0a
commit
b6f82c72b9
15 changed files with 453 additions and 592 deletions
53
tests/cli_tests/test_mbreorder.py
Normal file
53
tests/cli_tests/test_mbreorder.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
from ocrd_modelfactory import page_from_file
|
||||
from ocrd_models.constants import NAMESPACES as NS
|
||||
|
||||
from eynollah.cli import (
|
||||
machine_based_reading_order as mbreorder_cli,
|
||||
)
|
||||
|
||||
|
||||
def test_run_eynollah_mbreorder_filename(
|
||||
tmp_path,
|
||||
resources_dir,
|
||||
run_eynollah_ok_and_check_logs,
|
||||
):
|
||||
infile = resources_dir / 'kant_aufklaerung_1784_0020.xml'
|
||||
outfile = tmp_path.joinpath('kant_aufklaerung_1784_0020.xml')
|
||||
run_eynollah_ok_and_check_logs(
|
||||
mbreorder_cli,
|
||||
[
|
||||
'-i', str(infile),
|
||||
'-o', str(outfile.parent),
|
||||
],
|
||||
[
|
||||
# FIXME: mbreorder has no logging!
|
||||
]
|
||||
)
|
||||
assert outfile.exists()
|
||||
#in_tree = page_from_file(str(infile)).etree
|
||||
#in_order = in_tree.xpath("//page:OrderedGroup//@regionRef", namespaces=NS)
|
||||
out_tree = page_from_file(str(outfile)).etree
|
||||
out_order = out_tree.xpath("//page:OrderedGroup//@regionRef", namespaces=NS)
|
||||
#assert len(out_order) >= 2, "result is inaccurate"
|
||||
#assert in_order != out_order
|
||||
assert out_order == ['r_1_1', 'r_2_1', 'r_2_2', 'r_2_3']
|
||||
|
||||
def test_run_eynollah_mbreorder_directory(
|
||||
tmp_path,
|
||||
resources_dir,
|
||||
run_eynollah_ok_and_check_logs,
|
||||
):
|
||||
outfile = tmp_path.joinpath('kant_aufklaerung_1784_0020.xml')
|
||||
outdir = tmp_path
|
||||
run_eynollah_ok_and_check_logs(
|
||||
mbreorder_cli,
|
||||
[
|
||||
'-di', str(resources_dir),
|
||||
'-o', str(outdir),
|
||||
],
|
||||
[
|
||||
# FIXME: mbreorder has no logging!
|
||||
]
|
||||
)
|
||||
assert len(list(outdir.iterdir())) == 2
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue