2022-04-09 20:46:09 +00:00
|
|
|
from bopytex.planner.default_planner import default_tasks_builder
|
|
|
|
from bopytex.planner.only_corr_planner import only_corr_tasks_builder
|
2022-04-09 13:33:28 +00:00
|
|
|
from bopytex.tasks import Task
|
|
|
|
|
|
|
|
|
2022-04-09 20:46:09 +00:00
|
|
|
def test_tasks_builder_generate():
|
|
|
|
tasks = default_tasks_builder(
|
2022-04-09 20:29:58 +00:00
|
|
|
options={
|
|
|
|
"template": "tpl_source.tex",
|
|
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
|
|
"no_pdf": True,
|
|
|
|
}
|
2022-04-09 13:33:28 +00:00
|
|
|
)
|
|
|
|
assert tasks == [
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "01"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "02"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="02_source.tex",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2022-04-09 13:42:00 +00:00
|
|
|
|
2022-04-09 20:46:09 +00:00
|
|
|
def test_tasks_builder_generate_compile():
|
|
|
|
tasks = default_tasks_builder(
|
2022-04-09 20:29:58 +00:00
|
|
|
options={
|
|
|
|
"template": "tpl_source.tex",
|
|
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
|
|
"no_join": True,
|
|
|
|
}
|
2022-04-09 13:33:28 +00:00
|
|
|
)
|
|
|
|
assert tasks == [
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "01"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.tex"],
|
|
|
|
output="01_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "02"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="02_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["02_source.tex"],
|
|
|
|
output="02_source.pdf",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2022-04-09 13:42:00 +00:00
|
|
|
|
2022-04-09 20:46:09 +00:00
|
|
|
def test_tasks_builder_generate_compile_join():
|
|
|
|
tasks = default_tasks_builder(
|
2022-04-09 20:29:58 +00:00
|
|
|
options={
|
|
|
|
"template": "tpl_source.tex",
|
|
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
|
|
}
|
2022-04-09 13:33:28 +00:00
|
|
|
)
|
|
|
|
assert tasks == [
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "01"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.tex"],
|
|
|
|
output="01_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "02"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="02_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["02_source.tex"],
|
|
|
|
output="02_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="JOIN",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.pdf", "02_source.pdf"],
|
2022-04-09 13:42:00 +00:00
|
|
|
output="joined_source.pdf",
|
|
|
|
),
|
2022-04-09 13:33:28 +00:00
|
|
|
]
|
|
|
|
|
2022-04-09 13:42:00 +00:00
|
|
|
|
2022-04-09 20:46:09 +00:00
|
|
|
def test_tasks_builder_generate_compile_corr():
|
|
|
|
tasks = default_tasks_builder(
|
2022-04-09 20:29:58 +00:00
|
|
|
options={
|
|
|
|
"template": "tpl_source.tex",
|
|
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
|
|
"corr": 1,
|
|
|
|
"no_join": 1,
|
|
|
|
}
|
2022-04-09 13:33:28 +00:00
|
|
|
)
|
|
|
|
assert tasks == [
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "01"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.tex"],
|
|
|
|
output="01_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="ACTIVATE_CORR",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.tex"],
|
|
|
|
output="corr_01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["corr_01_source.tex"],
|
|
|
|
output="corr_01_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "02"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="02_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["02_source.tex"],
|
|
|
|
output="02_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="ACTIVATE_CORR",
|
|
|
|
args={},
|
|
|
|
deps=["02_source.tex"],
|
|
|
|
output="corr_02_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["corr_02_source.tex"],
|
|
|
|
output="corr_02_source.pdf",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2022-04-09 13:42:00 +00:00
|
|
|
|
2022-04-09 20:46:09 +00:00
|
|
|
def test_tasks_builder_generate_compile_corr_joined():
|
|
|
|
tasks = default_tasks_builder(
|
2022-04-09 20:29:58 +00:00
|
|
|
options={
|
|
|
|
"template": "tpl_source.tex",
|
|
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
|
|
"corr": True,
|
|
|
|
"no_join": False,
|
|
|
|
}
|
2022-04-09 13:33:28 +00:00
|
|
|
)
|
|
|
|
assert tasks == [
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "01"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.tex"],
|
|
|
|
output="01_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="ACTIVATE_CORR",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.tex"],
|
|
|
|
output="corr_01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["corr_01_source.tex"],
|
|
|
|
output="corr_01_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="GENERATE",
|
|
|
|
args={"number": "02"},
|
|
|
|
deps=["tpl_source.tex"],
|
|
|
|
output="02_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["02_source.tex"],
|
|
|
|
output="02_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="ACTIVATE_CORR",
|
|
|
|
args={},
|
|
|
|
deps=["02_source.tex"],
|
|
|
|
output="corr_02_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["corr_02_source.tex"],
|
|
|
|
output="corr_02_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="JOIN",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.pdf", "02_source.pdf"],
|
2022-04-09 13:42:00 +00:00
|
|
|
output="joined_source.pdf",
|
2022-04-09 13:33:28 +00:00
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="JOIN",
|
|
|
|
args={},
|
|
|
|
deps=["corr_01_source.pdf", "corr_02_source.pdf"],
|
2022-04-09 13:42:00 +00:00
|
|
|
output="corr_joined_source.pdf",
|
|
|
|
),
|
2022-04-09 13:33:28 +00:00
|
|
|
]
|
|
|
|
|
2022-04-09 20:06:42 +00:00
|
|
|
|
2022-04-09 20:46:09 +00:00
|
|
|
def test_only_corr_tasks_builder():
|
|
|
|
tasks = only_corr_tasks_builder(
|
2022-04-09 20:29:58 +00:00
|
|
|
options={
|
|
|
|
"sources": ["01_source.tex", "02_source.tex"],
|
|
|
|
}
|
2022-04-09 13:42:00 +00:00
|
|
|
)
|
|
|
|
assert tasks == [
|
|
|
|
Task(
|
|
|
|
action="ACTIVATE_CORR",
|
|
|
|
args={},
|
|
|
|
deps=["01_source.tex"],
|
|
|
|
output="corr_01_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["corr_01_source.tex"],
|
|
|
|
output="corr_01_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="ACTIVATE_CORR",
|
|
|
|
args={},
|
|
|
|
deps=["02_source.tex"],
|
|
|
|
output="corr_02_source.tex",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="COMPILE",
|
|
|
|
args={},
|
|
|
|
deps=["corr_02_source.tex"],
|
|
|
|
output="corr_02_source.pdf",
|
|
|
|
),
|
|
|
|
Task(
|
|
|
|
action="JOIN",
|
|
|
|
args={},
|
|
|
|
deps=["corr_01_source.pdf", "corr_02_source.pdf"],
|
|
|
|
output="corr_joined.pdf",
|
|
|
|
),
|
|
|
|
]
|