From ecda6ebe744ccfd650ff1884a7889c5a3c1bce23 Mon Sep 17 00:00:00 2001
From: thomahl <thomahl@stud.ntnu.no>
Date: Thu, 16 Apr 2020 11:13:34 +0200
Subject: [PATCH] #70 test for plassering av vedleggsmoduler

---
 soitool/inline_editable_soi_view.py |  2 +-
 test/test_soi.py                    | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/soitool/inline_editable_soi_view.py b/soitool/inline_editable_soi_view.py
index de2e505..5a67259 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 c281d8d..03bdd7e 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.
-- 
GitLab