2022-04-13 20:14:27 +00:00
|
|
|
import os
|
|
|
|
import jinja2
|
|
|
|
from pathlib import Path
|
|
|
|
from bopytex.message import Message
|
2022-04-16 05:30:47 +00:00
|
|
|
from bopytex.planner.generate_compile_join_planner import planner
|
2022-04-13 20:14:27 +00:00
|
|
|
from bopytex.service import orcherstrator
|
|
|
|
from bopytex.worker import Dispatcher
|
|
|
|
from bopytex.worker.clean import clean
|
|
|
|
from bopytex.worker.compile import latexmk
|
|
|
|
from bopytex.worker.generate import generate
|
|
|
|
from bopytex.worker.join_pdf import pdfjam
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def template_path(tmp_path):
|
|
|
|
template = tmp_path / "tpl_source.tex"
|
|
|
|
with open(template, "w") as tpl:
|
|
|
|
tpl.write(
|
|
|
|
"""
|
|
|
|
\\documentclass{article}
|
|
|
|
|
|
|
|
\\begin{document}
|
|
|
|
First document.
|
|
|
|
|
|
|
|
Subject {{ subject }}
|
|
|
|
\\end{document}
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
return template
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def jinja2_env(tmp_path):
|
|
|
|
templateEnv = jinja2.Environment(loader=jinja2.FileSystemLoader(tmp_path))
|
|
|
|
return templateEnv
|
|
|
|
|
|
|
|
|
|
|
|
def test_with_default_planner(template_path, jinja2_env, tmp_path):
|
|
|
|
os.chdir(tmp_path)
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"template": str(template_path.name),
|
|
|
|
"quantity_subjects": 3,
|
|
|
|
"corr": False,
|
|
|
|
"no_join": False,
|
|
|
|
"no_pdf": False,
|
|
|
|
"jinja2": {
|
|
|
|
"environment": jinja2_env,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
dispatcher = Dispatcher(
|
|
|
|
{"GENERATE": generate, "COMPILE": latexmk, "JOIN": pdfjam, "CLEAN": clean}
|
|
|
|
)
|
2022-04-16 05:30:47 +00:00
|
|
|
orcherstre = orcherstrator(options, planner=planner, dispatcher=dispatcher)
|
2022-04-13 20:14:27 +00:00
|
|
|
|
|
|
|
messages = []
|
|
|
|
for message in orcherstre:
|
|
|
|
assert message.status == 0
|
|
|
|
|
|
|
|
assert Path("joined_source.pdf").exists()
|