Skip to content
Snippets Groups Projects
Commit 7a8e807d authored by morkolai's avatar morkolai
Browse files

#96 Fullført tester.

parent 16e77a22
No related branches found
No related tags found
1 merge request!57#96 Telefonliste & Fiks til høyde på tabeller (rundt oppløsning)
Pipeline #83639 failed
......@@ -4,7 +4,12 @@ import unittest
from PySide2.QtGui import qApp, QKeySequence
from PySide2.QtCore import Qt, QTimer
from PySide2.QtTest import QTest
from PySide2.QtWidgets import QApplication, QCheckBox, QPushButton
from PySide2.QtWidgets import (
QApplication,
QCheckBox,
QPushButton,
QTableWidgetItem,
)
from soitool.soi import SOI
from soitool.modules.module_phonebook import (
PhonebookModule,
......@@ -30,14 +35,14 @@ class TestPhonebokkModule(unittest.TestCase):
"""Test header is correct."""
self.assertEqual(self.phonebook.header.text(), "Telefonliste")
def test_type_table(self):
def test_resize_width(self):
"""Test able to type in table and resize to content."""
rambo_quote = "Live for nothing or die for something."
self.phonebook.table.setCurrentCell(1, 0)
QTest.keyClicks(self.phonebook.table, rambo_quote)
print(self.phonebook.table.currentItem().text())
# TODO
item = QTableWidgetItem(rambo_quote)
old_width = self.phonebook.minimumWidth()
self.phonebook.table.setItem(1, 0, item)
new_width = self.phonebook.minimumWidth()
self.assertGreater(new_width, old_width)
def test_popup(self):
"""Test popup is shown and i able to edit columns."""
......@@ -64,18 +69,21 @@ class TestPhonebokkModule(unittest.TestCase):
new_column_count = visible_columns_in(self.phonebook.table)
self.assertEqual(new_column_count, old_column_count + 1)
def test_add_row(self):
"""Test adding row."""
def test_add_row_and_resize(self):
"""Test adding row and resizes acordingly."""
old_row_count = self.phonebook.table.rowCount()
old_height = self.phonebook.minimumHeight()
QTest.keySequence(
self.phonebook, QKeySequence(Qt.ControlModifier + Qt.Key_Plus)
)
new_row_count = self.phonebook.table.rowCount()
new_height = self.phonebook.minimumHeight()
self.assertEqual(new_row_count, old_row_count + 1)
self.assertGreater(new_height, old_height)
def test_remove_row(self):
"""Test removing row."""
self.phonebook.table.setRowCount(self.phonebook.table.rowCount() + 1)
self.phonebook.table.setRowCount(self.phonebook.table.rowCount() + 5)
old_row_count = self.phonebook.table.rowCount()
self.phonebook.table.setCurrentCell(1, 0)
QTest.keySequence(
......@@ -84,8 +92,14 @@ class TestPhonebokkModule(unittest.TestCase):
new_row_count = self.phonebook.table.rowCount()
self.assertEqual(new_row_count, old_row_count - 1)
def test_buttons_visibility(self):
"""Test buttons only are visible when mouse is in widgets space."""
self.assertFalse(self.phonebook.buttons.isVisible())
QTest.mouseMove(self.phonebook.buttons)
self.assertTrue(self.phonebook.table.isVisible())
def test_add_to_soi_smoke_test(self):
"""Test that can add to SOI sccessfully."""
"""Test that can add to SOI successfully."""
soi = SOI()
test_name = "Test name"
soi.add_module(test_name, self.phonebook, False)
......@@ -125,6 +139,13 @@ class TestPhonebookModuleWithDataParameter(unittest.TestCase):
current_text, self.data[column_header][row_index - 1]
)
def test_add_to_soi_smoketest(self):
"""Test that can add to SOI successfully."""
soi = SOI()
test_name = "Test name"
soi.add_module(test_name, self.phonebook, False)
self.assertTrue(soi.module_name_taken(test_name))
def visible_columns_in(table):
"""Count number of visible columns in a table.
......
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