Miscs personal GUI improvement
This commit is contained in:
@@ -4,13 +4,14 @@ import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from tkinter import ttk
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from copienator import CliError, EvaluationWorkspace, ExitCode
|
||||
from copienator.commands import enonce_info as personal
|
||||
from copienator.commands import gemini_for_enonce as gemini
|
||||
from copienator_gui.app import CopienatorApp
|
||||
from copienator_gui.app import CopienatorApp, get_personal_interro_files
|
||||
from copienator_gui.workflow import build_workflow
|
||||
|
||||
|
||||
@@ -53,7 +54,7 @@ class PersonalStatementTests(unittest.TestCase):
|
||||
enabled = {step.id: step for step in build_workflow(True)}
|
||||
self.assertEqual([variant.id for variant in standard["statement"].variants], ["gemini"])
|
||||
self.assertEqual([variant.program for variant in enabled["statement"].variants],
|
||||
["statement", "statement-personal"])
|
||||
["statement-personal", "statement"])
|
||||
for ident in ("statement_groups", "statement_persp"):
|
||||
self.assertNotIn(ident, standard)
|
||||
self.assertTrue(enabled[ident].optional)
|
||||
@@ -140,6 +141,48 @@ class SelectiveGeminiTests(unittest.TestCase):
|
||||
|
||||
@unittest.skipUnless(os.environ.get("DISPLAY"), "Tk requires a display")
|
||||
class PersonalStatementGuiTests(unittest.TestCase):
|
||||
def test_get_file_button_completes_inputs_and_advances(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
repository = Path(temporary)
|
||||
evaluation = repository / "Interro12"
|
||||
source = repository / "source"
|
||||
evaluation.mkdir()
|
||||
source.mkdir()
|
||||
(repository / "names").touch()
|
||||
for name, content in (
|
||||
("Interro12.pdf", b"pdf"),
|
||||
("Interro12.tex", b"statement"),
|
||||
("Interro12c.tex", b"correction"),
|
||||
):
|
||||
(source / name).write_bytes(content)
|
||||
app = CopienatorApp(repository, True, evaluation)
|
||||
try:
|
||||
app.update()
|
||||
buttons = [
|
||||
child
|
||||
for child in app.form.winfo_children()
|
||||
if isinstance(child, ttk.Button)
|
||||
]
|
||||
get_button = next(
|
||||
button for button in buttons if button.cget("text") == "Get the files"
|
||||
)
|
||||
with patch(
|
||||
"copienator_gui.app.get_personal_interro_files",
|
||||
side_effect=lambda target: get_personal_interro_files(target, source),
|
||||
):
|
||||
get_button.invoke()
|
||||
app.update()
|
||||
|
||||
self.assertEqual(app.state_store.step("inputs")["status"], "success")
|
||||
self.assertEqual(app.current_step.id, "statement")
|
||||
self.assertEqual((evaluation / "enonce.pdf").read_bytes(), b"pdf")
|
||||
self.assertEqual((evaluation / "enonce.tex").read_bytes(), b"statement")
|
||||
self.assertEqual((evaluation / "correction.tex").read_bytes(), b"correction")
|
||||
finally:
|
||||
for callback in app.tk.splitlist(app.tk.call("after", "info")):
|
||||
app.after_cancel(callback)
|
||||
app.destroy()
|
||||
|
||||
def test_personal_requirements_and_optional_button_command_previews(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
evaluation = Path(temporary)
|
||||
@@ -149,12 +192,19 @@ class PersonalStatementGuiTests(unittest.TestCase):
|
||||
app.update()
|
||||
app.tree.selection_set("statement")
|
||||
app.update()
|
||||
app._select_variant(1)
|
||||
self.assertEqual(app.variant_var.get(), "personal")
|
||||
self.assertIn("statement-personal", app.command_var.get())
|
||||
self.assertEqual(app._missing_requirements(app.current_step), [])
|
||||
self.assertIn("SHEETINFO", app.description_label.cget("text"))
|
||||
self.assertFalse(
|
||||
any(
|
||||
isinstance(child, ttk.LabelFrame)
|
||||
and child.cget("text") == "Après génération — facultatif"
|
||||
for child in app.form.winfo_children()
|
||||
)
|
||||
)
|
||||
for ident, flag in (("statement_groups", "--groups-only"), ("statement_persp", "--persp-only")):
|
||||
app._select_statement_action(ident)
|
||||
app.tree.selection_set(ident)
|
||||
app.update()
|
||||
self.assertEqual(app.current_step.id, ident)
|
||||
self.assertIn(flag, app.command_var.get())
|
||||
|
||||
Reference in New Issue
Block a user