This commit is contained in:
sebastien committed 2026-10-21 22:28:27 +02:00
1 parent 0d8970061e
commit c30aac0572
14 files changed
+343 -48

No files matched your search

+40
View File
@@ -16,6 +16,36 @@ from copienator_gui.workflow import build_workflow
class PersonalStatementTests(unittest.TestCase):
def test_sheetinfo_numbering_controls_labels_and_summary(self):
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
blocks = [
{"id": 42, "numbering": "problem", "indexes": [{"indices": [1, 3]}]},
{"id": 99, "numbering": "problem_abc", "indexes": [
{"indices": [1, 3]}, {"indices": [1, 1, 1]}]},
{"id": 100, "numbering": "exercise", "indexes": [{"indices": [1, 2]}]},
]
# Explicit metadata takes precedence over the old Roman heuristic.
(root / "enonce.tex").write_text("\n".join(
"%%SHEETINFO : " + json.dumps(block) + "\n\\Roman" for block in blocks))
def fetch(url):
if "/emacs/" in url:
return io.BytesIO(b" 1. Section\n c. Part\n 1. Question\n"
b"###Solution\n c. Answer\n###Rubric\n c. Points")
return io.BytesIO(b"Selected question")
with patch.object(personal.urllib.request, "urlopen", side_effect=fetch), \
patch.object(personal, "compile_to_pdf"):
self.assertEqual(personal.process_directory(EvaluationWorkspace(root)), ExitCode.SUCCESS)
expected = ["Ex 1 : I)3)", "Ex 2 : I)C)", "Ex 2 : I)A)1)", "Ex 3 : 1)b)"]
self.assertEqual((root / "labels").read_text().splitlines(), expected)
for label in expected:
for folder in ("Text2", "Sol2"):
self.assertTrue((root / folder / (label + ".tex")).is_file())
for folder in ("Text", "Sol", "Persp"):
self.assertIn(" C)", (root / folder / "Ex 2").read_text())
def test_personal_generation_uses_statement_and_groups_by_exercise(self):
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
@@ -95,6 +125,16 @@ class SelectiveGeminiTests(unittest.TestCase):
before.pop("label_groups")
self.assertEqual(after, before)
def test_grouping_follows_label_order_instead_of_gemini_order(self):
self.client.models.generate_content.return_value = self.response({
"groups": [[self.labels[2]], [self.labels[1], self.labels[0]]],
})
self.assertEqual(gemini.refine_existing(self.workspace, "groups", api_client=self.client), ExitCode.SUCCESS)
self.assertEqual(
self.workspace.label_groups_file.read_text(),
", ".join(self.labels[:2]) + "\n" + self.labels[2] + "\n",
)
def test_invalid_grouping_preserves_existing_groups(self):
before = self.snapshot()
for groups in ([[self.labels[0]]], [[*self.labels, self.labels[0]]], [[*self.labels, "invented"]]):