diff --git a/soitool/inline_editable_soi_view.py b/soitool/inline_editable_soi_view.py index de2e5054188c38d5c880e39b8c1aa66f58472fe6..5a67259a3827247cf2e9826b19387f8a1e5f60c5 100644 --- a/soitool/inline_editable_soi_view.py +++ b/soitool/inline_editable_soi_view.py @@ -16,7 +16,7 @@ from soitool.soi import ModuleLargerThanBinError from soitool.dialog_wrappers import exec_warning_dialog from soitool.serialize_export_import_soi import generate_soi_filename -# how attachment pages should be numbered. The first page should be numbered +# How attachment pages should be numbered. The first page should be numbered # by the value of ATTACHMENT_NUMBERING_SCHEME[0], the second page # ATTACHMENT_NUMBERING_SCHEME[1], and so on. ATTACHMENT_NUMBERING_SCHEME = list(string.ascii_uppercase) diff --git a/test/test_soi.py b/test/test_soi.py index c281d8d93f30ce882b349e9431552cccff56d400..03bdd7e929f74145b45b4ba110941279433ec9dc 100644 --- a/test/test_soi.py +++ b/test/test_soi.py @@ -414,6 +414,31 @@ class TestSOI(unittest.TestCase): lambda: self.soi.update_properties(invalid_key="garbage"), ) + def test_reorganize_attachments(self): + """Test that calling reorganize properly reorganized attachments. + + Attachments should appear on their own pages, starting after the last + non-attachment page. The attachments should be placed at the top-left + corner. + """ + self.soi.reorganize() + + # Modules of SOI from self.setUp will all be placed on first page, so + # expect the three attachment modules also from self.setUp on pages + # 2,3,4 + self.assertEqual( + self.soi.attachments[0]["meta"], + {"x": 0, "y": 0, "page": 2, "name": "tall_module"}, + ) + self.assertEqual( + self.soi.attachments[1]["meta"], + {"x": 0, "y": 0, "page": 3, "name": "wide_module"}, + ) + self.assertEqual( + self.soi.attachments[2]["meta"], + {"x": 0, "y": 0, "page": 4, "name": "big_module"}, + ) + def deep_copy_of_modules_list(modules, widget_cloner): """Get deep copy of modules list. Works for both modules and attachments.