387 lines
11 KiB
Python
387 lines
11 KiB
Python
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,
|
|
)
|
|
from bopytex.tasks import Task
|
|
|
|
|
|
def test_tasks_builder_generate():
|
|
tasks = gcj_task_builder(
|
|
options={
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"no_pdf": True,
|
|
}
|
|
)
|
|
assert tasks == [
|
|
Task(
|
|
action="GENERATE",
|
|
args={
|
|
"options": {
|
|
"no_pdf": True,
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"number": "01"},
|
|
},
|
|
deps=["tpl_source.tex"],
|
|
output="01_source.tex",
|
|
),
|
|
Task(
|
|
action="GENERATE",
|
|
args={
|
|
"options": {
|
|
"no_pdf": True,
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"number": "02"},
|
|
},
|
|
deps=["tpl_source.tex"],
|
|
output="02_source.tex",
|
|
),
|
|
]
|
|
|
|
|
|
def test_tasks_builder_generate_compile():
|
|
tasks = gcj_task_builder(
|
|
options={
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"no_join": True,
|
|
}
|
|
)
|
|
assert tasks == [
|
|
Task(
|
|
action="GENERATE",
|
|
args={
|
|
"options": {
|
|
"no_join": True,
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"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={
|
|
"options": {
|
|
"no_join": True,
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"number": "02"},
|
|
},
|
|
deps=["tpl_source.tex"],
|
|
output="02_source.tex",
|
|
),
|
|
Task(
|
|
action="COMPILE",
|
|
args={},
|
|
deps=["02_source.tex"],
|
|
output="02_source.pdf",
|
|
),
|
|
]
|
|
|
|
|
|
def test_tasks_builder_generate_compile_join():
|
|
tasks = gcj_task_builder(
|
|
options={
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
}
|
|
)
|
|
assert tasks == [
|
|
Task(
|
|
action="GENERATE",
|
|
args={
|
|
"options": {
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"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={
|
|
"options": {
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"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"],
|
|
output="joined_source.pdf",
|
|
),
|
|
]
|
|
|
|
|
|
def test_tasks_builder_generate_compile_corr():
|
|
tasks = gcj_task_builder(
|
|
options={
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"corr": True,
|
|
"no_join": True,
|
|
}
|
|
)
|
|
assert tasks == [
|
|
Task(
|
|
action="GENERATE",
|
|
args={
|
|
"options": {
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"corr": True,
|
|
"no_join": True,
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"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={
|
|
"corr": True,
|
|
"no_join": True,
|
|
"no_pdf": False,
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
},
|
|
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={
|
|
"options": {
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"corr": True,
|
|
"no_join": True,
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"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={
|
|
"corr": True,
|
|
"no_join": True,
|
|
"no_pdf": False,
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
},
|
|
deps=["02_source.tex"],
|
|
output="corr_02_source.tex",
|
|
),
|
|
Task(
|
|
action="COMPILE",
|
|
args={},
|
|
deps=["corr_02_source.tex"],
|
|
output="corr_02_source.pdf",
|
|
),
|
|
]
|
|
|
|
|
|
def test_tasks_builder_generate_compile_corr_joined():
|
|
tasks = gcj_task_builder(
|
|
options={
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"corr": True,
|
|
"no_join": False,
|
|
}
|
|
)
|
|
assert tasks == [
|
|
Task(
|
|
action="GENERATE",
|
|
args={
|
|
"options": {
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"corr": True,
|
|
"no_join": False,
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"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={
|
|
"corr": True,
|
|
"no_join": False,
|
|
"no_pdf": False,
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
},
|
|
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={
|
|
"options": {
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
"corr": True,
|
|
"no_join": False,
|
|
"template": "tpl_source.tex",
|
|
},
|
|
"subject": {"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={
|
|
"corr": True,
|
|
"no_join": False,
|
|
"no_pdf": False,
|
|
"template": "tpl_source.tex",
|
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
|
},
|
|
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"],
|
|
output="joined_source.pdf",
|
|
),
|
|
Task(
|
|
action="JOIN",
|
|
args={},
|
|
deps=["corr_01_source.pdf", "corr_02_source.pdf"],
|
|
output="corr_joined_source.pdf",
|
|
),
|
|
]
|
|
|
|
|
|
def test_only_corr_tasks_builder():
|
|
tasks = accj_task_builder(
|
|
options={
|
|
"sources": ["01_source.tex", "02_source.tex"],
|
|
}
|
|
)
|
|
assert tasks == [
|
|
Task(
|
|
action="ACTIVATE_CORR",
|
|
args={
|
|
"no_join": False,
|
|
"no_pdf": False,
|
|
"sources": ["01_source.tex", "02_source.tex"],
|
|
},
|
|
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={
|
|
"no_join": False,
|
|
"no_pdf": False,
|
|
"sources": ["01_source.tex", "02_source.tex"],
|
|
},
|
|
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",
|
|
),
|
|
]
|