miscs
This commit is contained in:
1 parent
c30aac0572
commit
834ffe32f2
7 files changed
+116
-14
No files matched your search
@@ -12,6 +12,7 @@ from copienator.annotation_layout import (
|
||||
move_answer_pdf, save_parts,
|
||||
)
|
||||
from copienator.commands import annotating, annotating_by_label, splitting_int
|
||||
from copienator.commands.annotating_with_checks import CheckboxRenderer
|
||||
from copienator.commands import reading_grouped_annotations as reader
|
||||
from copienator.left_margin import analyse_margins
|
||||
from copienator.pdf_cut import split_pdf
|
||||
@@ -113,6 +114,26 @@ class AnnotationLayoutTests(unittest.TestCase):
|
||||
self.assertEqual(low.getpixel((400, height + 80)), (0, 0, 255))
|
||||
self.assertEqual(low.getpixel((399, height + 80)), (255, 255, 255))
|
||||
|
||||
def test_later_rectangle_cannot_draw_inside_comment_checkbox(self):
|
||||
renderer = CheckboxRenderer('Ex 1')
|
||||
result = {'score': 2, 'feedback': [
|
||||
{'text': 'First comment', 'box_2d': [10, 50, 50, 200]},
|
||||
{'text': 'Later rectangle', 'box_2d': [10, 300, 80, 400]},
|
||||
]}
|
||||
with patch.object(annotating, 'render_score_text', return_value=Image.new('RGB', (800, 80), 'white')):
|
||||
image, _ = annotating.compose_label_image(
|
||||
Image.new('RGB', (1654, 100), 'white'), 'Ex 1', result, 0,
|
||||
render_fn=lambda *args, **kwargs: Image.new('RGBA', (620, 50), (255, 200, 200, 180)),
|
||||
draw_callback=renderer.callback, layout=legacy_layout())
|
||||
# The later rectangle's left edge crosses the first comment's checkbox.
|
||||
checkbox = next(item for item in renderer.checkboxes
|
||||
if item['type'] == 'del_local' and item['index'] == 0)
|
||||
x1, y1, x2, y2 = checkbox['final_box']
|
||||
interior = image.crop((x1 + 5, y1 + 5, x2 - 5, y2 - 5))
|
||||
self.assertEqual(interior.getextrema(), ((255, 255),) * 3)
|
||||
# The rectangle still exists outside the checkbox.
|
||||
self.assertEqual(image.getpixel((650, 90)), (255, 0, 0))
|
||||
|
||||
def test_mixed_bgnot_widths_and_saved_geometry_survive_config_change(self):
|
||||
normal, height, _ = self.render(legacy_layout())
|
||||
low, _, _ = self.render({**legacy_layout(), 'margin_left': 400})
|
||||
|
||||
Reference in new issue
Block a user