Skip to content
Snippets Groups Projects
Commit 1119f67e authored by Anders H. Rebner's avatar Anders H. Rebner
Browse files

#146 Autentiseringstavle og subtraktorkoder modifisert

parent 505d85fc
No related branches found
No related tags found
1 merge request!84#146 Modifiser autentiseringstavle og subtraktorkoder
Pipeline #83778 failed
...@@ -43,7 +43,7 @@ class AuthenticationBoardModule(CodeTableBase): ...@@ -43,7 +43,7 @@ class AuthenticationBoardModule(CodeTableBase):
The default widget-initialization has a headline, a row-count of The default widget-initialization has a headline, a row-count of
START_NO_OF_CODES and three columns. START_NO_OF_CODES and three columns.
Row x in the first column contains the character ROW_IDENTIFIERS[x]. 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 Row x in the third column contains an authentication code of length
CODE_LENGTH, spaced out for readability if SPACE_INTERVAL and SPACE_AMOUNT CODE_LENGTH, spaced out for readability if SPACE_INTERVAL and SPACE_AMOUNT
is larger than 0. is larger than 0.
...@@ -109,7 +109,8 @@ class AuthenticationBoardModule(CodeTableBase): ...@@ -109,7 +109,8 @@ class AuthenticationBoardModule(CodeTableBase):
self.setItem(i, 0, item_first) self.setItem(i, 0, item_first)
# Insert non-editable row identifier (int) in second column # 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.setTextAlignment(Qt.AlignCenter)
item_second.setFlags(item_second.flags() ^ Qt.ItemIsEditable) item_second.setFlags(item_second.flags() ^ Qt.ItemIsEditable)
self.setItem(i, 1, item_second) self.setItem(i, 1, item_second)
...@@ -137,7 +138,8 @@ class AuthenticationBoardModule(CodeTableBase): ...@@ -137,7 +138,8 @@ class AuthenticationBoardModule(CodeTableBase):
self.setItem(i, 0, item_first) self.setItem(i, 0, item_first)
# Insert row identifier (int) in second column # 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.setTextAlignment(Qt.AlignCenter)
item_second.setFlags(item_second.flags() ^ Qt.ItemIsEditable) item_second.setFlags(item_second.flags() ^ Qt.ItemIsEditable)
self.setItem(i, 1, item_second) self.setItem(i, 1, item_second)
...@@ -167,7 +169,8 @@ class AuthenticationBoardModule(CodeTableBase): ...@@ -167,7 +169,8 @@ class AuthenticationBoardModule(CodeTableBase):
# If first row is removed, identifier A,B,C becomes A,B (not B,C) # If first row is removed, identifier A,B,C becomes A,B (not B,C)
for i in range(row_index, self.rowCount()): for i in range(row_index, self.rowCount()):
self.item(i, 0).setText(self.code_characters[i - 1]) 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) resize_table(self, columns=False, rows=False, has_headline=True)
def generate_authentication_numbers(self): def generate_authentication_numbers(self):
......
...@@ -69,6 +69,9 @@ class SubtractorcodesModule(CodeTableBase): ...@@ -69,6 +69,9 @@ class SubtractorcodesModule(CodeTableBase):
self.space_amount = SPACE_AMOUNT self.space_amount = SPACE_AMOUNT
CodeTableBase.__init__(self, size, data) 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): def insert_row_identifiers(self, has_headline=False):
"""Insert row identifiers in first and second column. """Insert row identifiers in first and second column.
......
...@@ -74,7 +74,8 @@ class TestDefaultAuthenticationBoardAndSubtractorcodesModule( ...@@ -74,7 +74,8 @@ class TestDefaultAuthenticationBoardAndSubtractorcodesModule(
self.assertEqual(self.subtractor.columnCount(), 3) self.assertEqual(self.subtractor.columnCount(), 3)
# Assert cell content in first and second column is correct # 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.assertEqual(
self.authentication.item(i, 0).text(), self.authentication.item(i, 0).text(),
ROW_IDENTIFIERS_AUTHENTICATION[i - 1], ROW_IDENTIFIERS_AUTHENTICATION[i - 1],
...@@ -162,9 +163,7 @@ class TestDefaultAuthenticationBoardAndSubtractorcodesModule( ...@@ -162,9 +163,7 @@ class TestDefaultAuthenticationBoardAndSubtractorcodesModule(
self.authentication.item(row_index, 0).text(), self.authentication.item(row_index, 0).text(),
ROW_IDENTIFIERS_AUTHENTICATION[row_index - 1], ROW_IDENTIFIERS_AUTHENTICATION[row_index - 1],
) )
self.assertEqual( self.assertEqual(self.authentication.item(row_index, 1).text(), "")
self.authentication.item(row_index, 1).text(), str(row_index - 1)
)
new_code = self.authentication.item(row_index, 2).text() new_code = self.authentication.item(row_index, 2).text()
existing_code = self.authentication.item(1, 2).text() existing_code = self.authentication.item(1, 2).text()
self.assertEqual(len(new_code), len(existing_code)) self.assertEqual(len(new_code), len(existing_code))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment