a bit of cleanup
This commit is contained in:
@ -1,24 +1,25 @@
|
||||
import unittest
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMdiArea
|
||||
from PyQt5.QtGui import QPainter
|
||||
|
||||
|
||||
from grum.mainwin import MainWindow
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from grum.mainwin import MainWindow
|
||||
from grum.mdi import MDIArea, MDISubMultiPlot, MDISubPlot
|
||||
from grum.mdi.mdisubwin import MDISubWindow
|
||||
from grum.theme import MDI_BKG
|
||||
|
||||
from PyQt5.QtGui import QPainter
|
||||
from PyQt5.QtWidgets import QApplication, QMdiArea
|
||||
|
||||
|
||||
class TestViewUnit(unittest.TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
print("setup")
|
||||
self.app = QApplication(sys.argv)
|
||||
self.mw = MainWindow()
|
||||
self.mw.show()
|
||||
|
||||
|
||||
def tearDown(self) -> None:
|
||||
print("teardown")
|
||||
self.mw.rst.wait_for_stop()
|
||||
@ -27,6 +28,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
del self.mw
|
||||
del self.app
|
||||
|
||||
|
||||
def test_on_cascade(self):
|
||||
mdi = self.mw.mdi
|
||||
|
||||
@ -41,6 +43,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
mdi.enable_subwindow_view.assert_called_once()
|
||||
mdi.cascadeSubWindows.assert_called_once()
|
||||
|
||||
|
||||
def test_on_tile(self):
|
||||
mdi = self.mw.mdi
|
||||
|
||||
@ -55,6 +58,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
mdi.enable_subwindow_view.assert_called_once()
|
||||
mdi.tileSubWindows.assert_called_once()
|
||||
|
||||
|
||||
def test_enable_single_window_mode(self):
|
||||
mdi = self.mw.mdi
|
||||
mdi.enable_subwindow_view = mock.MagicMock()
|
||||
@ -79,6 +83,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
# active.showMaximized()
|
||||
# active.frame_off()
|
||||
|
||||
|
||||
def test_enable_subwindow_view(self):
|
||||
mdi = self.mw.mdi
|
||||
|
||||
@ -94,6 +99,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
sub.frame_on.assert_called_once()
|
||||
|
||||
|
||||
def test_enable_tabbed_view(self):
|
||||
mdi = self.mw.mdi
|
||||
mdi.setViewMode = mock.MagicMock()
|
||||
@ -101,6 +107,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
mdi.enable_tabbed_view()
|
||||
mdi.setViewMode.assert_called_once_with(QMdiArea.TabbedView)
|
||||
|
||||
|
||||
def test_add(self):
|
||||
mdi =self.mw.mdi
|
||||
sine_item = self.mw.lst.lst.get("sine")
|
||||
@ -118,6 +125,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
mdi.add(sub)
|
||||
mdi.add_single.assert_called_once_with(sub)
|
||||
|
||||
|
||||
def test_add_multiple(self):
|
||||
mdi = self.mw.mdi
|
||||
mdi.addSubWindow = mock.MagicMock()
|
||||
@ -129,6 +137,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
mdi.addSubWindow.assert_called_once()
|
||||
sub.show.assert_called_once()
|
||||
|
||||
|
||||
def test_add_single(self):
|
||||
mdi = self.mw.mdi
|
||||
mdi.addSubWindow = mock.MagicMock()
|
||||
@ -144,7 +153,8 @@ class TestViewUnit(unittest.TestCase):
|
||||
mdi.addSubWindow.assert_called_once_with(sub)
|
||||
sub.showMaximized.assert_called_once()
|
||||
sub.frame_off.assert_called_once()
|
||||
|
||||
|
||||
|
||||
def test_paintEvent(self):
|
||||
mdi = self.mw.mdi
|
||||
|
||||
@ -152,8 +162,8 @@ class TestViewUnit(unittest.TestCase):
|
||||
mdi.paintEvent('event')
|
||||
mdi._draw_watermark.assert_called_once()
|
||||
|
||||
def test_findSubWindow(self):
|
||||
|
||||
def test_findSubWindow(self):
|
||||
mdi = self.mw.mdi
|
||||
sine_item = self.mw.lst.lst.get("sine")
|
||||
sub = MDISubPlot("sine", sine_item.value)
|
||||
@ -167,8 +177,8 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
assert ret == None
|
||||
|
||||
def test_closeInactiveSubWindows(self):
|
||||
|
||||
def test_closeInactiveSubWindows(self):
|
||||
mdi = self.mw.mdi
|
||||
|
||||
sine_item = self.mw.lst.lst.get("sine")
|
||||
@ -187,3 +197,6 @@ class TestViewUnit(unittest.TestCase):
|
||||
for sub in mdi.subWindowList():
|
||||
if sub != active:
|
||||
sub.close.assert_called_once()
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user