Fix: run pre-commit hooks
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from bopytex.worker import Dispatcher
|
||||
from .workers import fake_worker, success_worker, fail_worker
|
||||
|
||||
from .workers import fail_worker, fake_worker, success_worker
|
||||
|
||||
fake_dispatcher = Dispatcher(
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from bopytex.message import Message
|
||||
|
||||
|
||||
def fake_worker(args, deps, output):
|
||||
return Message(0, [f"FAKE - {args} - {deps} - {output}"], [])
|
||||
|
||||
@@ -10,4 +11,3 @@ def success_worker(args, deps, output):
|
||||
|
||||
def fail_worker(args, deps, output):
|
||||
return Message(1, [f"FAILURE - {args} - {deps} - {output}"], [])
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import os
|
||||
import jinja2
|
||||
from pathlib import Path
|
||||
from bopytex.service import main
|
||||
|
||||
import jinja2
|
||||
import pytest
|
||||
|
||||
from bopytex.service import main
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def template_path(tmp_path):
|
||||
@@ -22,6 +24,7 @@ Subject {{ number }}
|
||||
)
|
||||
return template
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bad_template_path(tmp_path):
|
||||
template = tmp_path / "tpl_source.tex"
|
||||
@@ -64,6 +67,7 @@ def test_with_default_planner(template_path, jinja2_env, tmp_path):
|
||||
|
||||
assert Path("joined_source.pdf").exists()
|
||||
|
||||
|
||||
def test_with_default_planner_bad_template(bad_template_path, jinja2_env, tmp_path):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
@@ -82,4 +86,3 @@ def test_with_default_planner_bad_template(bad_template_path, jinja2_env, tmp_pa
|
||||
pass
|
||||
|
||||
assert not Path("joined_source.pdf").exists()
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
from bopytex.planner.generate_compile_join_planner import tasks_builder as gcj_task_builder
|
||||
from bopytex.planner.activate_corr_compile_join_planner import tasks_builder as accj_task_builder
|
||||
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
|
||||
|
||||
|
||||
@@ -18,9 +22,9 @@ def test_tasks_builder_generate():
|
||||
"options": {
|
||||
"no_pdf": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"}
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
@@ -31,9 +35,9 @@ def test_tasks_builder_generate():
|
||||
"options": {
|
||||
"no_pdf": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"}
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
@@ -56,9 +60,9 @@ def test_tasks_builder_generate_compile():
|
||||
"options": {
|
||||
"no_join": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"}
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
@@ -75,9 +79,9 @@ def test_tasks_builder_generate_compile():
|
||||
"options": {
|
||||
"no_join": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"}
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
@@ -104,9 +108,9 @@ def test_tasks_builder_generate_compile_join():
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"}
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
@@ -122,9 +126,9 @@ def test_tasks_builder_generate_compile_join():
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"}
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
@@ -161,9 +165,9 @@ def test_tasks_builder_generate_compile_corr():
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": True,
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"}
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
@@ -177,12 +181,12 @@ def test_tasks_builder_generate_compile_corr():
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
'corr': True,
|
||||
'no_join': True,
|
||||
'no_pdf': False,
|
||||
'template': 'tpl_source.tex',
|
||||
"subjects": [{'number': '01'}, {'number': '02'}]
|
||||
},
|
||||
"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",
|
||||
),
|
||||
@@ -199,9 +203,9 @@ def test_tasks_builder_generate_compile_corr():
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": True,
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"}
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
@@ -215,12 +219,12 @@ def test_tasks_builder_generate_compile_corr():
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
'corr': True,
|
||||
'no_join': True,
|
||||
'no_pdf': False,
|
||||
'template': 'tpl_source.tex',
|
||||
"subjects": [{'number': '01'}, {'number': '02'}]
|
||||
},
|
||||
"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",
|
||||
),
|
||||
@@ -250,9 +254,9 @@ def test_tasks_builder_generate_compile_corr_joined():
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": False,
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"}
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
@@ -266,12 +270,12 @@ def test_tasks_builder_generate_compile_corr_joined():
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
'corr': True,
|
||||
'no_join': False,
|
||||
'no_pdf': False,
|
||||
'template': 'tpl_source.tex',
|
||||
"subjects": [{'number': '01'}, {'number': '02'}]
|
||||
},
|
||||
"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",
|
||||
),
|
||||
@@ -288,9 +292,9 @@ def test_tasks_builder_generate_compile_corr_joined():
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": False,
|
||||
'template': 'tpl_source.tex',
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"}
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
@@ -304,12 +308,12 @@ def test_tasks_builder_generate_compile_corr_joined():
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
'corr': True,
|
||||
'no_join': False,
|
||||
'no_pdf': False,
|
||||
'template': 'tpl_source.tex',
|
||||
"subjects": [{'number': '01'}, {'number': '02'}]
|
||||
},
|
||||
"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",
|
||||
),
|
||||
@@ -344,10 +348,10 @@ def test_only_corr_tasks_builder():
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
'no_join': False,
|
||||
'no_pdf': False,
|
||||
'sources': ['01_source.tex', '02_source.tex']
|
||||
},
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"sources": ["01_source.tex", "02_source.tex"],
|
||||
},
|
||||
deps=["01_source.tex"],
|
||||
output="corr_01_source.tex",
|
||||
),
|
||||
@@ -360,10 +364,10 @@ def test_only_corr_tasks_builder():
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
'no_join': False,
|
||||
'no_pdf': False,
|
||||
'sources': ['01_source.tex', '02_source.tex']
|
||||
},
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"sources": ["01_source.tex", "02_source.tex"],
|
||||
},
|
||||
deps=["02_source.tex"],
|
||||
output="corr_02_source.tex",
|
||||
),
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from bopytex.message import Message
|
||||
from bopytex.tasks import Task
|
||||
from bopytex.scheduler import Scheduler
|
||||
from .fakes.dispatcher import fake_dispatcher
|
||||
import pytest
|
||||
|
||||
from bopytex.message import Message
|
||||
from bopytex.scheduler import Scheduler
|
||||
from bopytex.tasks import Task
|
||||
|
||||
from .fakes.dispatcher import fake_dispatcher
|
||||
|
||||
|
||||
def test_schedule_append():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from bopytex.planner import fake_planner
|
||||
from bopytex.service import build_config, orcherstrator
|
||||
from bopytex.tasks import Task
|
||||
from bopytex.worker import Dispatcher
|
||||
|
||||
from .fakes.workers import fake_worker
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ def test_block_line_statement():
|
||||
output = jinja2_template.render()
|
||||
assert output == "2"
|
||||
|
||||
|
||||
def test_block_line_statement_with_comment():
|
||||
base_template = r"""%-set a = 2
|
||||
%# comment
|
||||
@@ -30,11 +31,10 @@ def test_block_line_statement_with_comment():
|
||||
output = jinja2_template.render()
|
||||
assert output == "\n2"
|
||||
|
||||
|
||||
def test_add_filter():
|
||||
texenv.filters["count_caracters"] = lambda x: len(x)
|
||||
base_template = r"""\Var{a} has \Var{a | count_caracters}"""
|
||||
jinja2_template = texenv.from_string(base_template)
|
||||
output = jinja2_template.render(a="coucou")
|
||||
assert output == "coucou has 6"
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import os
|
||||
|
||||
from pathlib import Path
|
||||
from bopytex.worker.compile import latexmk
|
||||
|
||||
import pytest
|
||||
|
||||
from bopytex.worker.compile import latexmk
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tex_path(tmp_path):
|
||||
@@ -14,7 +15,7 @@ def tex_path(tmp_path):
|
||||
\\documentclass{article}
|
||||
|
||||
\\begin{document}
|
||||
First document. This is a simple example, with no
|
||||
First document. This is a simple example, with no
|
||||
extra parameters or packages included.
|
||||
\\end{document}
|
||||
"""
|
||||
@@ -23,7 +24,7 @@ extra parameters or packages included.
|
||||
|
||||
|
||||
def test_latexmk(tex_path, tmp_path):
|
||||
#tmp_path = tex_path.parent
|
||||
# tmp_path = tex_path.parent
|
||||
os.chdir(tmp_path)
|
||||
|
||||
texfile = str(tex_path.name)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import os
|
||||
|
||||
import jinja2
|
||||
from bopytex.worker.generate import generate
|
||||
import pytest
|
||||
|
||||
from bopytex.worker.generate import generate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jinja2_env(tmp_path):
|
||||
@@ -31,9 +33,9 @@ def test_generate(template_path, jinja2_env):
|
||||
"options": {
|
||||
"direct_access": {"a": 2},
|
||||
"jinja2": {"environment": jinja2_env},
|
||||
},
|
||||
"subject": {},
|
||||
},
|
||||
"subject": {},
|
||||
},
|
||||
deps=[template],
|
||||
output=output,
|
||||
)
|
||||
@@ -70,10 +72,10 @@ def test_generate_with_random(template_path_with_random, jinja2_env):
|
||||
"jinja2": {"environment": jinja2_env},
|
||||
"direct_access": {
|
||||
"random": random,
|
||||
}
|
||||
},
|
||||
"subject":{},
|
||||
},
|
||||
"subject": {},
|
||||
},
|
||||
deps=[template],
|
||||
output=output,
|
||||
)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import os
|
||||
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from bopytex.worker.join_pdf import pdfjam
|
||||
|
||||
import pytest
|
||||
|
||||
from bopytex.worker.join_pdf import pdfjam
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def multiple_pdf(tmp_path, request):
|
||||
|
||||
Reference in New Issue
Block a user