eynollah/tests/cli_tests/test_mbreorder.py

59 lines
1.6 KiB
Python
Raw Normal View History

2026-07-20 12:32:54 +02:00
import pytest
2025-10-29 16:20:30 +01:00
from ocrd_modelfactory import page_from_file
from ocrd_models.constants import NAMESPACES as NS
2026-07-20 12:32:54 +02:00
@pytest.mark.parametrize(
"options",
[
[], # defaults
["--model_based"],
], ids=str)
2025-10-29 16:20:30 +01:00
def test_run_eynollah_mbreorder_filename(
tmp_path,
resources_dir,
run_eynollah_ok_and_check_logs,
2026-07-20 12:32:54 +02:00
options,
2025-10-29 16:20:30 +01:00
):
2025-11-13 11:46:31 +01:00
infile = resources_dir / '2files/kant_aufklaerung_1784_0020.xml'
outfile = tmp_path /'kant_aufklaerung_1784_0020.xml'
2025-10-29 16:20:30 +01:00
run_eynollah_ok_and_check_logs(
2026-07-20 12:32:54 +02:00
'reorder',
2025-10-29 16:20:30 +01:00
[
'-i', str(infile),
2026-07-20 12:32:54 +02:00
'-dim', str(resources_dir / '2files'),
2025-10-29 16:20:30 +01:00
'-o', str(outfile.parent),
2026-07-20 12:32:54 +02:00
] + options,
2025-10-29 16:20:30 +01:00
[
2026-07-20 12:32:54 +02:00
str(infile)
2025-10-29 16:20:30 +01:00
]
)
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,
):
outdir = tmp_path
run_eynollah_ok_and_check_logs(
2026-07-20 12:32:54 +02:00
'reorder',
2025-10-29 16:20:30 +01:00
[
2025-11-13 11:46:31 +01:00
'-di', str(resources_dir / '2files'),
2026-07-20 12:32:54 +02:00
'-dim', str(resources_dir / '2files'),
2025-10-29 16:20:30 +01:00
'-o', str(outdir),
],
[
2026-07-20 12:32:54 +02:00
'Job done in',
'All jobs done in',
2025-10-29 16:20:30 +01:00
]
)
assert len(list(outdir.iterdir())) == 2