Bopytex/test/test_planner.py

387 lines
11 KiB
Python
Raw Permalink Normal View History

2022-07-28 07:39:51 +00:00
from bopytex.planner.activate_corr_compile_join_planner import (
tasks_builder as accj_task_builder,
)
from bopytex.planner.generate_compile_join_planner import (
tasks_builder as gcj_task_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():
2022-04-16 05:30:47 +00:00
tasks = gcj_task_builder(
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",
2022-04-13 20:14:27 +00:00
args={
"options": {
"no_pdf": True,
"subjects": [{"number": "01"}, {"number": "02"}],
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "01"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
deps=["tpl_source.tex"],
output="01_source.tex",
),
Task(
action="GENERATE",
2022-04-13 20:14:27 +00:00
args={
"options": {
"no_pdf": True,
"subjects": [{"number": "01"}, {"number": "02"}],
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "02"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
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():
2022-04-16 05:30:47 +00:00
tasks = gcj_task_builder(
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",
2022-04-13 20:14:27 +00:00
args={
"options": {
"no_join": True,
"subjects": [{"number": "01"}, {"number": "02"}],
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "01"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
deps=["tpl_source.tex"],
output="01_source.tex",
),
Task(
action="COMPILE",
args={},
deps=["01_source.tex"],
output="01_source.pdf",
),
Task(
action="GENERATE",
2022-04-13 20:14:27 +00:00
args={
"options": {
"no_join": True,
"subjects": [{"number": "01"}, {"number": "02"}],
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "02"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
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():
2022-04-16 05:30:47 +00:00
tasks = gcj_task_builder(
options={
"template": "tpl_source.tex",
"subjects": [{"number": "01"}, {"number": "02"}],
}
2022-04-09 13:33:28 +00:00
)
assert tasks == [
Task(
action="GENERATE",
2022-04-13 20:14:27 +00:00
args={
"options": {
"subjects": [{"number": "01"}, {"number": "02"}],
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "01"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
deps=["tpl_source.tex"],
output="01_source.tex",
),
Task(
action="COMPILE",
args={},
deps=["01_source.tex"],
output="01_source.pdf",
),
Task(
action="GENERATE",
2022-04-13 20:14:27 +00:00
args={
"options": {
"subjects": [{"number": "01"}, {"number": "02"}],
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "02"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
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():
2022-04-16 05:30:47 +00:00
tasks = gcj_task_builder(
options={
"template": "tpl_source.tex",
"subjects": [{"number": "01"}, {"number": "02"}],
2022-04-13 20:14:27 +00:00
"corr": True,
"no_join": True,
}
2022-04-09 13:33:28 +00:00
)
assert tasks == [
Task(
action="GENERATE",
2022-04-13 20:14:27 +00:00
args={
"options": {
"subjects": [{"number": "01"}, {"number": "02"}],
"corr": True,
"no_join": True,
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "01"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
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={
2022-07-28 07:39:51 +00:00
"corr": True,
"no_join": True,
"no_pdf": False,
"template": "tpl_source.tex",
"subjects": [{"number": "01"}, {"number": "02"}],
},
2022-04-09 13:33:28 +00:00
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",
2022-04-13 20:14:27 +00:00
args={
"options": {
"subjects": [{"number": "01"}, {"number": "02"}],
"corr": True,
"no_join": True,
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "02"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
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={
2022-07-28 07:39:51 +00:00
"corr": True,
"no_join": True,
"no_pdf": False,
"template": "tpl_source.tex",
"subjects": [{"number": "01"}, {"number": "02"}],
},
2022-04-09 13:33:28 +00:00
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():
2022-04-16 05:30:47 +00:00
tasks = gcj_task_builder(
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",
2022-04-13 20:14:27 +00:00
args={
"options": {
"subjects": [{"number": "01"}, {"number": "02"}],
"corr": True,
"no_join": False,
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "01"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
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={
2022-07-28 07:39:51 +00:00
"corr": True,
"no_join": False,
"no_pdf": False,
"template": "tpl_source.tex",
"subjects": [{"number": "01"}, {"number": "02"}],
},
2022-04-09 13:33:28 +00:00
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",
2022-04-13 20:14:27 +00:00
args={
"options": {
"subjects": [{"number": "01"}, {"number": "02"}],
"corr": True,
"no_join": False,
2022-07-28 07:39:51 +00:00
"template": "tpl_source.tex",
},
2022-07-28 07:39:51 +00:00
"subject": {"number": "02"},
2022-04-13 20:14:27 +00:00
},
2022-04-09 13:33:28 +00:00
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={
2022-07-28 07:39:51 +00:00
"corr": True,
"no_join": False,
"no_pdf": False,
"template": "tpl_source.tex",
"subjects": [{"number": "01"}, {"number": "02"}],
},
2022-04-09 13:33:28 +00:00
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:46:09 +00:00
def test_only_corr_tasks_builder():
2022-04-16 05:30:47 +00:00
tasks = accj_task_builder(
options={
"sources": ["01_source.tex", "02_source.tex"],
}
2022-04-09 13:42:00 +00:00
)
assert tasks == [
Task(
action="ACTIVATE_CORR",
args={
2022-07-28 07:39:51 +00:00
"no_join": False,
"no_pdf": False,
"sources": ["01_source.tex", "02_source.tex"],
},
2022-04-09 13:42:00 +00:00
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={
2022-07-28 07:39:51 +00:00
"no_join": False,
"no_pdf": False,
"sources": ["01_source.tex", "02_source.tex"],
},
2022-04-09 13:42:00 +00:00
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",
),
]