Remove `Arguments supplémentaires' boxes
This commit is contained in:
@@ -116,7 +116,7 @@ class CropExerciseBottomsCommandTests(unittest.TestCase):
|
||||
self.assertEqual(steps[index - 1].id, "splitting")
|
||||
self.assertEqual(steps[index + 1].id, "grouping")
|
||||
self.assertTrue(steps[index].optional)
|
||||
self.assertFalse(steps[index].auto_start_first_visit)
|
||||
self.assertTrue(steps[index].auto_start_first_visit)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -182,7 +182,7 @@ class CropMarginsCommandTests(unittest.TestCase):
|
||||
self.assertEqual(steps[index-1].id, "page_splitter")
|
||||
self.assertEqual(steps[index+1].id, "cutleft")
|
||||
self.assertTrue(steps[index].optional)
|
||||
self.assertFalse(steps[index].auto_start_first_visit)
|
||||
self.assertTrue(steps[index].auto_start_first_visit)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -27,6 +27,18 @@ class GuiConvenienceTests(unittest.TestCase):
|
||||
self.app.destroy()
|
||||
self.temp.cleanup()
|
||||
|
||||
@staticmethod
|
||||
def _label_texts(widget):
|
||||
return [
|
||||
text
|
||||
for child in widget.winfo_children()
|
||||
for text in (
|
||||
[str(child.cget("text"))]
|
||||
if isinstance(child, ttk.Label)
|
||||
else GuiConvenienceTests._label_texts(child)
|
||||
)
|
||||
]
|
||||
|
||||
def test_reload_detects_added_and_removed_files_without_advancing(self):
|
||||
for name in ("enonce.pdf", "enonce.tex", "correction.tex"):
|
||||
(self.evaluation / name).touch()
|
||||
@@ -57,6 +69,7 @@ class GuiConvenienceTests(unittest.TestCase):
|
||||
copies.mkdir()
|
||||
source = copies/"Copie01.pdf"
|
||||
source.touch()
|
||||
self.app.state_store.update_step("crop_blank_margins", visited=True)
|
||||
self.app.tree.selection_set("crop_blank_margins")
|
||||
self.app.update()
|
||||
self.assertEqual(self.app.current_step.id, "crop_blank_margins")
|
||||
@@ -72,6 +85,7 @@ class GuiConvenienceTests(unittest.TestCase):
|
||||
answers = self.evaluation / "Copies" / "Copie01"
|
||||
answers.mkdir(parents=True)
|
||||
(answers / "Ex 1.pdf").touch()
|
||||
self.app.state_store.update_step("crop_exercise_bottoms", visited=True)
|
||||
self.app.tree.selection_set("crop_exercise_bottoms")
|
||||
self.app.update()
|
||||
self.assertEqual(self.app.current_step.id, "crop_exercise_bottoms")
|
||||
@@ -135,6 +149,24 @@ class GuiConvenienceTests(unittest.TestCase):
|
||||
self.assertIn("Cibler la copie sélectionnée", controls)
|
||||
self.assertIn("Cibler tout le dossier", controls)
|
||||
|
||||
def test_free_form_arguments_are_shown_only_when_documented(self):
|
||||
self.app.tree.selection_set("labels")
|
||||
self.app.update()
|
||||
labels_text = self._label_texts(self.app.form)
|
||||
self.assertIn("Arguments supplémentaires", labels_text)
|
||||
self.assertTrue(any("Cutleft" in text for text in labels_text))
|
||||
|
||||
self.app.tree.selection_set("plotting")
|
||||
self.app.update()
|
||||
self.assertNotIn("Arguments supplémentaires", self._label_texts(self.app.form))
|
||||
|
||||
def test_verbose_checkbox_updates_supported_commands(self):
|
||||
self.app.tree.selection_set("labels")
|
||||
self.app.update()
|
||||
self.assertNotIn("--verbose", self.app._make_command())
|
||||
self.app.verbose_var.set(True)
|
||||
self.assertIn("--verbose", self.app._make_command())
|
||||
|
||||
def test_console_selection_survives_output_and_is_read_only(self):
|
||||
self.app._append_console("Première ligne\nDeuxième ligne\n")
|
||||
self.app.console.tag_add("sel", "1.0", "1.end")
|
||||
|
||||
+116
-1
@@ -1674,12 +1674,37 @@ class WorkflowTests(unittest.TestCase):
|
||||
if step.skip_without_manual_conflicts
|
||||
}
|
||||
|
||||
self.assertEqual(auto_start, {"splitting", "grouping"})
|
||||
self.assertEqual(
|
||||
auto_start,
|
||||
{"crop_blank_margins", "splitting", "crop_exercise_bottoms", "grouping"},
|
||||
)
|
||||
self.assertEqual(
|
||||
skip_for_live, {"submit_batches", "batch_status", "fetch_batches"}
|
||||
)
|
||||
self.assertEqual(skip_without_conflicts, {"manual_resolution"})
|
||||
|
||||
def test_crop_auto_start_follows_always_crop_configuration(self) -> None:
|
||||
for enabled in (False, True):
|
||||
with self.subTest(enabled=enabled), patch(
|
||||
"copienator_gui.workflow.ALWAYS_CROP", enabled
|
||||
):
|
||||
steps = {step.id: step for step in build_workflow(False)}
|
||||
self.assertEqual(
|
||||
steps["crop_blank_margins"].auto_start_first_visit, enabled
|
||||
)
|
||||
self.assertEqual(
|
||||
steps["crop_exercise_bottoms"].auto_start_first_visit, enabled
|
||||
)
|
||||
self.assertTrue(steps["crop_blank_margins"].optional)
|
||||
self.assertTrue(steps["crop_exercise_bottoms"].optional)
|
||||
|
||||
def test_default_and_repository_crop_configuration(self) -> None:
|
||||
import config
|
||||
import default_config
|
||||
|
||||
self.assertFalse(default_config.ALWAYS_CROP)
|
||||
self.assertTrue(config.ALWAYS_CROP)
|
||||
|
||||
def test_review_persp_has_shorter_title(self) -> None:
|
||||
self.assertEqual(self.steps["review_persp"].title, "Relire les barèmes")
|
||||
|
||||
@@ -1790,6 +1815,82 @@ class WorkflowTests(unittest.TestCase):
|
||||
command_arguments(command), [self.evaluation, "--batch-from", "Ex 4"]
|
||||
)
|
||||
|
||||
def test_only_multi_target_steps_offer_free_form_arguments(self) -> None:
|
||||
documented = {
|
||||
step.id: step
|
||||
for step in self.steps.values()
|
||||
if step.extra_arguments_help
|
||||
}
|
||||
self.assertEqual(set(documented), {"labels", "correction"})
|
||||
self.assertIn("Cutleft", documented["labels"].extra_arguments_help)
|
||||
self.assertIn("Group_X.jpg", documented["correction"].extra_arguments_help)
|
||||
self.assertEqual(
|
||||
documented["correction"].extra_arguments_variants,
|
||||
("live", "batch", "hybrid", "refaire"),
|
||||
)
|
||||
|
||||
def test_options_previously_requiring_free_form_arguments_have_controls(self) -> None:
|
||||
status = self.command(
|
||||
"batch_status",
|
||||
"default",
|
||||
{"download": "files/job-1", "output": "/tmp/result.jsonl"},
|
||||
)
|
||||
self.assertEqual(
|
||||
command_arguments(status),
|
||||
["--download", "files/job-1", "--output", "/tmp/result.jsonl"],
|
||||
)
|
||||
|
||||
grouped = self.command(
|
||||
"read_annotations",
|
||||
"grouped",
|
||||
{
|
||||
"target": self.evaluation,
|
||||
"refaire": True,
|
||||
"annotation_dir": "Bnot",
|
||||
},
|
||||
)
|
||||
self.assertEqual(
|
||||
command_arguments(grouped),
|
||||
[self.evaluation, "--refaire", "--annotation-dir", "Bnot"],
|
||||
)
|
||||
|
||||
def test_verbose_is_added_only_to_commands_that_support_it(self) -> None:
|
||||
labels = self.steps["labels"]
|
||||
labels_command = build_command(
|
||||
REPOSITORY,
|
||||
labels,
|
||||
labels.variants[0],
|
||||
{"target": self.evaluation},
|
||||
self.evaluation,
|
||||
verbose=True,
|
||||
)
|
||||
self.assertEqual(command_arguments(labels_command), [self.evaluation, "--verbose"])
|
||||
|
||||
rotate = self.steps["rotate"]
|
||||
rotate_command = build_command(
|
||||
REPOSITORY,
|
||||
rotate,
|
||||
rotate.variants[0],
|
||||
{"target": self.evaluation},
|
||||
self.evaluation,
|
||||
verbose=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
command_arguments(rotate_command),
|
||||
["rotate", self.evaluation, "--verbose"],
|
||||
)
|
||||
|
||||
update = self.steps["update_ods"]
|
||||
update_command = build_command(
|
||||
REPOSITORY,
|
||||
update,
|
||||
update.variants[0],
|
||||
{"target": self.evaluation},
|
||||
self.evaluation,
|
||||
verbose=True,
|
||||
)
|
||||
self.assertNotIn("--verbose", update_command)
|
||||
|
||||
def test_annotation_variants_are_exclusive_commands(self) -> None:
|
||||
command = self.command(
|
||||
"annotation", "grouped", {"target": self.evaluation, "overwrite": True}
|
||||
@@ -1815,6 +1916,20 @@ class WorkflowTests(unittest.TestCase):
|
||||
),
|
||||
[self.evaluation, "--yes"],
|
||||
)
|
||||
preview = next(variant for variant in clean.variants if variant.id == "dry_run")
|
||||
self.assertFalse(preview.dangerous)
|
||||
self.assertEqual(
|
||||
command_arguments(
|
||||
build_command(
|
||||
REPOSITORY,
|
||||
clean,
|
||||
preview,
|
||||
{"target": self.evaluation},
|
||||
self.evaluation,
|
||||
)
|
||||
),
|
||||
[self.evaluation, "--dry-run"],
|
||||
)
|
||||
|
||||
|
||||
class CrossPlatformFileTests(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user