Skip to content
Snippets Groups Projects
Commit d08a3637 authored by Thomas Holene Løkkeborg's avatar Thomas Holene Løkkeborg
Browse files

#54 test for exception ved for store moduler

parent 98c2602a
No related branches found
No related tags found
1 merge request!28#54 Rectpack for reorganisering av moduler + litt black
......@@ -14,7 +14,7 @@ import unittest
from PySide2.QtWidgets import QApplication, QWidget
from PySide2 import QtGui
from PySide2.QtGui import QPalette, QColor
from soitool.soi import SOI
from soitool.soi import SOI, ModuleLargerThanBinError
from soitool.modules.module_base import ModuleBase
if isinstance(QtGui.qApp, type(None)):
......@@ -157,3 +157,43 @@ class TestSOI(unittest.TestCase):
self.soi.add_reorganization_listener(listener)
self.soi.reorganize()
self.assertTrue(listener_was_called)
def test_reorganize_of_too_big_module(self):
"""Test exception thrown by reorganize in case of too large modules."""
maximum_width = self.soi.CONTENT_WIDTH
maximum_height = self.soi.CONTENT_HEIGHT - self.soi.HEADER_HEIGHT
module_too_wide = {
"widget": TestModule("red", maximum_width + 1, 100),
"meta": {"x": 0, "y": 0, "page": 1, "name": "tall_module"},
}
module_too_tall = {
"widget": TestModule("red", 100, maximum_height + 1),
"meta": {"x": 0, "y": 0, "page": 1, "name": "tall_module"},
}
module_maximum_size = {
"widget": TestModule("red", maximum_width, maximum_height),
"meta": {"x": 0, "y": 0, "page": 1, "name": "tall_module"},
}
# too wide module should raise exception
self.soi.modules = [module_too_wide]
self.assertRaises(
ModuleLargerThanBinError, self.soi.reorganize,
)
# too tall module should raise exception
self.soi.modules = [module_too_tall]
self.assertRaises(
ModuleLargerThanBinError, self.soi.reorganize,
)
# module with maximum size shouldn't cause any exception
self.soi.modules = [module_maximum_size]
try:
self.soi.reorganize()
except ModuleLargerThanBinError:
self.fail(
"ModuleLargerThanBinError was raised even though module was "
"not too large"
)
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