From 1119f67efb74414578fd4f6f91d162cb96f9bf55 Mon Sep 17 00:00:00 2001
From: "Anders H. Rebner" <anderhre@stud.ntnu.no>
Date: Thu, 30 Apr 2020 19:53:19 +0200
Subject: [PATCH] #146 Autentiseringstavle og subtraktorkoder modifisert

---
 soitool/modules/module_authentication_board.py    | 11 +++++++----
 soitool/modules/module_subtractorcodes.py         |  3 +++
 test/test_module_authentication_and_subtractor.py |  7 +++----
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/soitool/modules/module_authentication_board.py b/soitool/modules/module_authentication_board.py
index 06ba84f..ea7a448 100644
--- a/soitool/modules/module_authentication_board.py
+++ b/soitool/modules/module_authentication_board.py
@@ -43,7 +43,7 @@ class AuthenticationBoardModule(CodeTableBase):
     The default widget-initialization has a headline, a row-count of
     START_NO_OF_CODES and three columns.
     Row x in the first column contains the character ROW_IDENTIFIERS[x].
-    Row x in the second column contains the character x.
+    Row x in the second column contains the character x, for x = 0-9.
     Row x in the third column contains an authentication code of length
     CODE_LENGTH, spaced out for readability if SPACE_INTERVAL and SPACE_AMOUNT
     is larger than 0.
@@ -109,7 +109,8 @@ class AuthenticationBoardModule(CodeTableBase):
             self.setItem(i, 0, item_first)
 
             # Insert non-editable row identifier (int) in second column
-            item_second = QTableWidgetItem(str(i))
+            text_second = str(i) if i < 10 else ""
+            item_second = QTableWidgetItem(text_second)
             item_second.setTextAlignment(Qt.AlignCenter)
             item_second.setFlags(item_second.flags() ^ Qt.ItemIsEditable)
             self.setItem(i, 1, item_second)
@@ -137,7 +138,8 @@ class AuthenticationBoardModule(CodeTableBase):
                 self.setItem(i, 0, item_first)
 
                 # Insert row identifier (int) in second column
-                item_second = QTableWidgetItem(str(i - 1))
+                text_second = str(i - 1) if i <= 10 else ""
+                item_second = QTableWidgetItem(text_second)
                 item_second.setTextAlignment(Qt.AlignCenter)
                 item_second.setFlags(item_second.flags() ^ Qt.ItemIsEditable)
                 self.setItem(i, 1, item_second)
@@ -167,7 +169,8 @@ class AuthenticationBoardModule(CodeTableBase):
         # If first row is removed, identifier A,B,C becomes A,B (not B,C)
         for i in range(row_index, self.rowCount()):
             self.item(i, 0).setText(self.code_characters[i - 1])
-            self.item(i, 1).setText(str(i - 1))
+            text_second = str(i - 1) if i <= 10 else ""
+            self.item(i, 1).setText(text_second)
         resize_table(self, columns=False, rows=False, has_headline=True)
 
     def generate_authentication_numbers(self):
diff --git a/soitool/modules/module_subtractorcodes.py b/soitool/modules/module_subtractorcodes.py
index 89d3f5c..3d8e763 100644
--- a/soitool/modules/module_subtractorcodes.py
+++ b/soitool/modules/module_subtractorcodes.py
@@ -69,6 +69,9 @@ class SubtractorcodesModule(CodeTableBase):
             self.space_amount = SPACE_AMOUNT
 
         CodeTableBase.__init__(self, size, data)
+        # The second column is hidden because it is not used in practice.
+        self.hideColumn(1)
+        resize_table(self, rows=False, columns=False, has_headline=True)
 
     def insert_row_identifiers(self, has_headline=False):
         """Insert row identifiers in first and second column.
diff --git a/test/test_module_authentication_and_subtractor.py b/test/test_module_authentication_and_subtractor.py
index 3eb4195..e8a913b 100644
--- a/test/test_module_authentication_and_subtractor.py
+++ b/test/test_module_authentication_and_subtractor.py
@@ -74,7 +74,8 @@ class TestDefaultAuthenticationBoardAndSubtractorcodesModule(
         self.assertEqual(self.subtractor.columnCount(), 3)
 
         # Assert cell content in first and second column is correct
-        for i in range(1, 3):  # From 1 to skip headline-row
+        # From 1 to skip headline-row
+        for i in range(1, START_NO_OF_CODES_SUBTRACTOR + 1):
             self.assertEqual(
                 self.authentication.item(i, 0).text(),
                 ROW_IDENTIFIERS_AUTHENTICATION[i - 1],
@@ -162,9 +163,7 @@ class TestDefaultAuthenticationBoardAndSubtractorcodesModule(
             self.authentication.item(row_index, 0).text(),
             ROW_IDENTIFIERS_AUTHENTICATION[row_index - 1],
         )
-        self.assertEqual(
-            self.authentication.item(row_index, 1).text(), str(row_index - 1)
-        )
+        self.assertEqual(self.authentication.item(row_index, 1).text(), "")
         new_code = self.authentication.item(row_index, 2).text()
         existing_code = self.authentication.item(1, 2).text()
         self.assertEqual(len(new_code), len(existing_code))
-- 
GitLab