Automatic orientation issues detection and fix, experimental
This commit is contained in:
1 parent
78a7b7679c
commit
46845c4612
12 files changed
+683
-9
No files matched your search
@@ -29,6 +29,41 @@ class GuiConvenienceTests(unittest.TestCase):
|
||||
self.app.destroy()
|
||||
self.temp.cleanup()
|
||||
|
||||
def test_orientation_report_buttons_flag_copies_and_launch_repair(self):
|
||||
from copienator import atomic_write_json
|
||||
from copienator.annotation_layout import fingerprint
|
||||
from copienator.copy_errors import copy_errors
|
||||
from copienator.orientation import report_path
|
||||
workspace = EvaluationWorkspace(self.evaluation)
|
||||
workspace.copies_dir.mkdir(exist_ok=True)
|
||||
pdf = workspace.copies_dir / 'Copie01.pdf'
|
||||
pdf.write_bytes(b'copy placeholder for UI')
|
||||
atomic_write_json(report_path(workspace, 'Copie01'), {
|
||||
'sha256': fingerprint(pdf), 'images': {'Copie01_01.jpg': [1, 2]},
|
||||
})
|
||||
self.app.current_step = self.app.step_by_id['labels']
|
||||
self.app._render_step()
|
||||
|
||||
def buttons(widget):
|
||||
result = []
|
||||
for child in widget.winfo_children():
|
||||
if isinstance(child, ttk.Button):
|
||||
result.append(child)
|
||||
result.extend(buttons(child))
|
||||
return result
|
||||
|
||||
next(b for b in buttons(self.app.form) if b.cget('text') == 'Signaler ces copies').invoke()
|
||||
self.assertIn('Copie01.pdf', copy_errors(workspace))
|
||||
automatic = next(b for b in buttons(self.app.form)
|
||||
if b.cget('text') == 'Corriger automatiquement l’orientation')
|
||||
with patch.object(self.app, '_validate_arguments', return_value=True), \
|
||||
patch.object(self.app, '_missing_requirements', return_value=[]), \
|
||||
patch.object(self.app.runner, 'start') as start:
|
||||
automatic.invoke()
|
||||
command = start.call_args.args[0]
|
||||
self.assertEqual(command[-2:], ['repair-orientation', str(self.evaluation)])
|
||||
self.assertEqual(self.app.active_step_id, 'labels')
|
||||
|
||||
def test_personal_review_commands_require_explicit_completion(self):
|
||||
from copienator_gui.workflow import build_workflow
|
||||
step = next(step for step in build_workflow(True) if step.id == "personal_read")
|
||||
|
||||
Reference in new issue
Block a user