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

#86 Fjernet 'fi' fra authentification

parent 81a58259
No related branches found
No related tags found
1 merge request!50#86 Modul: Autentiseringstavle
Pipeline #78307 failed
......@@ -31,10 +31,10 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
"""Modified QTableWidget representing a 'Autentifiseringstavle'.
By default, the widget initializes with a headline, a row-count of
START_NO_OF_AUTHENTIFICATION_CODES and three columns.
START_NO_OF_AUTHENTICATION_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 third column contains an authentification code.
Row x in the third column contains an authentication code.
If parameters are given, the widget initializes accordingly:
'size' is a dict: {"width": int, "height": int},
......@@ -49,7 +49,7 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
"""
def __init__(self, size=None, data=None):
self.type = "AuthentificationBoardModule"
self.type = "AuthenticationBoardModule"
QTableWidget.__init__(self)
ModuleBase.__init__(self)
......@@ -97,7 +97,7 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
self.insert_headline(data[0])
def generate_table(self):
"""Insert row identifiers and authentification codes."""
"""Insert row identifiers and authentication codes."""
# Set number of rows and columns
self.setRowCount(START_NO_OF_AUTHENTICATION_CODES)
self.setColumnCount(3)
......@@ -145,13 +145,13 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
self.setItem(0, 0, item_headline)
self.setSpan(0, 0, 1, self.columnCount()) # Make cell span all columns
def generate_unique_authentification_code(self):
"""Generate authentification-code that does not already exist.
def generate_unique_authentication_code(self):
"""Generate authentication-code that does not already exist.
Returns
-------
string
Generated, unique authentification-code
Generated, unique authentication-code
"""
# Get existing codes
existing_codes = self.get_codes()
......@@ -186,7 +186,7 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
# (+ 1 to skip row containing headline)
if self.rowCount() < len(ROW_IDENTIFIERS) + 1 and row_index != -1:
# Generate unique code and insert row
code = self.generate_unique_authentification_code()
code = self.generate_unique_authentication_code()
self.insertRow(row_index + 1)
# Loop through all rows starting with the new row
......@@ -201,7 +201,7 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
item_second.setFlags(item_second.flags() ^ Qt.ItemIsEditable)
self.setItem(i, 1, item_second)
# Insert authentification-code in third column
# Insert authentication-code in third column
item_third = QTableWidgetItem(code)
item_third.setFlags(item_third.flags() ^ Qt.ItemIsEditable)
self.setItem(row_index + 1, 2, item_third)
......@@ -227,12 +227,12 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
resize_table(self, resize_column=False)
def get_codes(self):
"""Get all authentification-codes in table.
"""Get all authentication-codes in table.
Returns
-------
List
List containing authentification-codes.
List containing authentication-codes.
"""
codes = []
......@@ -276,4 +276,4 @@ class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta):
@staticmethod
def get_icon():
"""Get icon of module."""
return QtGui.QIcon("soitool/media/authentificationboardmodule.png")
return QtGui.QIcon("soitool/media/authenticationboardmodule.png")
......@@ -221,7 +221,7 @@ def import_soi(file_path):
modules.append(
{"widget": TableModule(size, data), "meta": module["meta"]}
)
elif module_type == "AuthentificationBoardModule":
elif module_type == "AuthenticationBoardModule":
size = module["size"]
data = module["data"]
modules.append(
......
......@@ -58,10 +58,10 @@ class TestDefaultAuthenticationBoardModule(unittest.TestCase):
code_set = set(code_list)
self.assertEqual(len(code_list), len(code_set))
def test_generate_unique_authentification_code(self):
"""Test function generate_unique_authentification_module."""
def test_generate_unique_authentication_code(self):
"""Test function generate_unique_authentication_module."""
code_list = self.module.get_codes()
generated_code = self.module.generate_unique_authentification_code()
generated_code = self.module.generate_unique_authentication_code()
# Assert code length is equal to an existing code
self.assertEqual(len(generated_code), len(code_list[0]))
......
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