Feat: remise sur pieds pour les tests
This commit is contained in:
parent
ca2a47f82a
commit
04db450ceb
@ -1,2 +0,0 @@
|
|||||||
from .default_planner import default_planner
|
|
||||||
from .only_corr_planner import only_corr_planner
|
|
@ -11,16 +11,16 @@ def list_files(dir=".", accept=lambda _: True, reject=lambda _: False):
|
|||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
||||||
def only_corr_planner(options: dict) -> list[Task]:
|
def planner(options: dict) -> list[Task]:
|
||||||
sources = list_files(
|
sources = list_files(
|
||||||
accept=lambda x: x.endswith(".tex"),
|
accept=lambda x: x.endswith(".tex"),
|
||||||
reject=lambda x: x.startswith("tpl_"),
|
reject=lambda x: x.startswith("tpl_"),
|
||||||
)
|
)
|
||||||
options["sources"] = sources
|
options["sources"] = sources
|
||||||
return only_corr_tasks_builder(options)
|
return tasks_builder(options)
|
||||||
|
|
||||||
|
|
||||||
def only_corr_tasks_builder(
|
def tasks_builder(
|
||||||
options: dict,
|
options: dict,
|
||||||
) -> list[Task]:
|
) -> list[Task]:
|
||||||
opt = {
|
opt = {
|
@ -20,7 +20,7 @@ def build_subject_list_from_qty(qty: int) -> list[dict]:
|
|||||||
return subjects
|
return subjects
|
||||||
|
|
||||||
|
|
||||||
def default_planner(options: dict) -> list[Task]:
|
def planner(options: dict) -> list[Task]:
|
||||||
try:
|
try:
|
||||||
students_csv = options["students_csv"]
|
students_csv = options["students_csv"]
|
||||||
|
|
||||||
@ -37,10 +37,10 @@ def default_planner(options: dict) -> list[Task]:
|
|||||||
infos = csv.DictReader(csv_file)
|
infos = csv.DictReader(csv_file)
|
||||||
options["subjects"] = build_subject_list_from_infos(infos)
|
options["subjects"] = build_subject_list_from_infos(infos)
|
||||||
|
|
||||||
return default_tasks_builder(options)
|
return tasks_builder(options)
|
||||||
|
|
||||||
|
|
||||||
def default_tasks_builder(
|
def tasks_builder(
|
||||||
options: dict,
|
options: dict,
|
||||||
) -> list[Task]:
|
) -> list[Task]:
|
||||||
|
|
||||||
@ -67,8 +67,9 @@ def default_tasks_builder(
|
|||||||
|
|
||||||
for subject in subjects:
|
for subject in subjects:
|
||||||
source = naming.template2source(template, subject)
|
source = naming.template2source(template, subject)
|
||||||
|
args = {**subject, **options}
|
||||||
|
|
||||||
tasks.append(generate(template, {**subject, **opt}, source))
|
tasks.append(generate(template, args, source))
|
||||||
|
|
||||||
if not no_pdf:
|
if not no_pdf:
|
||||||
pdf = naming.source2pdf(source)
|
pdf = naming.source2pdf(source)
|
@ -2,7 +2,7 @@ import os
|
|||||||
import jinja2
|
import jinja2
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from bopytex.message import Message
|
from bopytex.message import Message
|
||||||
from bopytex.planner.default_planner import default_planner
|
from bopytex.planner.generate_compile_join_planner import planner
|
||||||
from bopytex.service import orcherstrator
|
from bopytex.service import orcherstrator
|
||||||
from bopytex.worker import Dispatcher
|
from bopytex.worker import Dispatcher
|
||||||
from bopytex.worker.clean import clean
|
from bopytex.worker.clean import clean
|
||||||
@ -52,7 +52,7 @@ def test_with_default_planner(template_path, jinja2_env, tmp_path):
|
|||||||
dispatcher = Dispatcher(
|
dispatcher = Dispatcher(
|
||||||
{"GENERATE": generate, "COMPILE": latexmk, "JOIN": pdfjam, "CLEAN": clean}
|
{"GENERATE": generate, "COMPILE": latexmk, "JOIN": pdfjam, "CLEAN": clean}
|
||||||
)
|
)
|
||||||
orcherstre = orcherstrator(options, planner=default_planner, dispatcher=dispatcher)
|
orcherstre = orcherstrator(options, planner=planner, dispatcher=dispatcher)
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
for message in orcherstre:
|
for message in orcherstre:
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from bopytex.planner.default_planner import default_tasks_builder
|
from bopytex.planner.generate_compile_join_planner import tasks_builder as gcj_task_builder
|
||||||
from bopytex.planner.only_corr_planner import only_corr_tasks_builder
|
from bopytex.planner.activate_corr_compile_join_planner import tasks_builder as accj_task_builder
|
||||||
from bopytex.tasks import Task
|
from bopytex.tasks import Task
|
||||||
|
|
||||||
|
|
||||||
def test_tasks_builder_generate():
|
def test_tasks_builder_generate():
|
||||||
tasks = default_tasks_builder(
|
tasks = gcj_task_builder(
|
||||||
options={
|
options={
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
@ -16,11 +16,9 @@ def test_tasks_builder_generate():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "01",
|
"number": "01",
|
||||||
"corr": False,
|
|
||||||
"no_join": False,
|
|
||||||
"no_pdf": True,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
|
"no_pdf": True,
|
||||||
},
|
},
|
||||||
deps=["tpl_source.tex"],
|
deps=["tpl_source.tex"],
|
||||||
output="01_source.tex",
|
output="01_source.tex",
|
||||||
@ -29,11 +27,9 @@ def test_tasks_builder_generate():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "02",
|
"number": "02",
|
||||||
"corr": False,
|
|
||||||
"no_join": False,
|
|
||||||
"no_pdf": True,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
|
"no_pdf": True,
|
||||||
},
|
},
|
||||||
deps=["tpl_source.tex"],
|
deps=["tpl_source.tex"],
|
||||||
output="02_source.tex",
|
output="02_source.tex",
|
||||||
@ -42,7 +38,7 @@ def test_tasks_builder_generate():
|
|||||||
|
|
||||||
|
|
||||||
def test_tasks_builder_generate_compile():
|
def test_tasks_builder_generate_compile():
|
||||||
tasks = default_tasks_builder(
|
tasks = gcj_task_builder(
|
||||||
options={
|
options={
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
@ -54,11 +50,9 @@ def test_tasks_builder_generate_compile():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "01",
|
"number": "01",
|
||||||
"corr": False,
|
|
||||||
"no_join": True,
|
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
|
"no_join": True,
|
||||||
},
|
},
|
||||||
deps=["tpl_source.tex"],
|
deps=["tpl_source.tex"],
|
||||||
output="01_source.tex",
|
output="01_source.tex",
|
||||||
@ -73,11 +67,9 @@ def test_tasks_builder_generate_compile():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "02",
|
"number": "02",
|
||||||
"corr": False,
|
|
||||||
"no_join": True,
|
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
|
"no_join": True,
|
||||||
},
|
},
|
||||||
deps=["tpl_source.tex"],
|
deps=["tpl_source.tex"],
|
||||||
output="02_source.tex",
|
output="02_source.tex",
|
||||||
@ -92,7 +84,7 @@ def test_tasks_builder_generate_compile():
|
|||||||
|
|
||||||
|
|
||||||
def test_tasks_builder_generate_compile_join():
|
def test_tasks_builder_generate_compile_join():
|
||||||
tasks = default_tasks_builder(
|
tasks = gcj_task_builder(
|
||||||
options={
|
options={
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
@ -103,9 +95,6 @@ def test_tasks_builder_generate_compile_join():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "01",
|
"number": "01",
|
||||||
"corr": False,
|
|
||||||
"no_join": False,
|
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
},
|
},
|
||||||
@ -122,9 +111,6 @@ def test_tasks_builder_generate_compile_join():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "02",
|
"number": "02",
|
||||||
"corr": False,
|
|
||||||
"no_join": False,
|
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
},
|
},
|
||||||
@ -147,7 +133,7 @@ def test_tasks_builder_generate_compile_join():
|
|||||||
|
|
||||||
|
|
||||||
def test_tasks_builder_generate_compile_corr():
|
def test_tasks_builder_generate_compile_corr():
|
||||||
tasks = default_tasks_builder(
|
tasks = gcj_task_builder(
|
||||||
options={
|
options={
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
@ -160,11 +146,10 @@ def test_tasks_builder_generate_compile_corr():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "01",
|
"number": "01",
|
||||||
"corr": True,
|
|
||||||
"no_join": True,
|
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
|
"corr": True,
|
||||||
|
"no_join": True,
|
||||||
},
|
},
|
||||||
deps=["tpl_source.tex"],
|
deps=["tpl_source.tex"],
|
||||||
output="01_source.tex",
|
output="01_source.tex",
|
||||||
@ -191,11 +176,10 @@ def test_tasks_builder_generate_compile_corr():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "02",
|
"number": "02",
|
||||||
"corr": True,
|
|
||||||
"no_join": True,
|
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
|
"corr": True,
|
||||||
|
"no_join": True,
|
||||||
},
|
},
|
||||||
deps=["tpl_source.tex"],
|
deps=["tpl_source.tex"],
|
||||||
output="02_source.tex",
|
output="02_source.tex",
|
||||||
@ -222,7 +206,7 @@ def test_tasks_builder_generate_compile_corr():
|
|||||||
|
|
||||||
|
|
||||||
def test_tasks_builder_generate_compile_corr_joined():
|
def test_tasks_builder_generate_compile_corr_joined():
|
||||||
tasks = default_tasks_builder(
|
tasks = gcj_task_builder(
|
||||||
options={
|
options={
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
@ -237,7 +221,6 @@ def test_tasks_builder_generate_compile_corr_joined():
|
|||||||
"number": "01",
|
"number": "01",
|
||||||
"corr": True,
|
"corr": True,
|
||||||
"no_join": False,
|
"no_join": False,
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
},
|
},
|
||||||
@ -266,11 +249,10 @@ def test_tasks_builder_generate_compile_corr_joined():
|
|||||||
action="GENERATE",
|
action="GENERATE",
|
||||||
args={
|
args={
|
||||||
"number": "02",
|
"number": "02",
|
||||||
"corr": True,
|
|
||||||
"no_join": False,
|
|
||||||
"no_pdf": False,
|
|
||||||
"template": "tpl_source.tex",
|
"template": "tpl_source.tex",
|
||||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||||
|
"corr": True,
|
||||||
|
"no_join": False,
|
||||||
},
|
},
|
||||||
deps=["tpl_source.tex"],
|
deps=["tpl_source.tex"],
|
||||||
output="02_source.tex",
|
output="02_source.tex",
|
||||||
@ -309,7 +291,7 @@ def test_tasks_builder_generate_compile_corr_joined():
|
|||||||
|
|
||||||
|
|
||||||
def test_only_corr_tasks_builder():
|
def test_only_corr_tasks_builder():
|
||||||
tasks = only_corr_tasks_builder(
|
tasks = accj_task_builder(
|
||||||
options={
|
options={
|
||||||
"sources": ["01_source.tex", "02_source.tex"],
|
"sources": ["01_source.tex", "02_source.tex"],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user