a bit of cleanup
This commit is contained in:
@ -1,29 +1,27 @@
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
# import pytest
|
||||
from PyQt5.QtWidgets import QApplication, QAction, QListWidget
|
||||
from grum.mainwin import MainWindow
|
||||
from grum.dictlist import DictList
|
||||
from unittest import mock
|
||||
from grum import ctrl_c, theme, assets
|
||||
|
||||
from grum.dictlist.dictlistitem import DictListItem
|
||||
from grum.plotdesc import PlotDescription
|
||||
from grum.menus.rclickmenu import RClickMenu
|
||||
from grum.menus import BarMenu
|
||||
from grum.mdi import MDIArea, MDISubMultiPlot, MDISubPlot
|
||||
|
||||
from grum.rpc import RPCServerThread
|
||||
from PyQt5.QtTest import QSignalSpy
|
||||
from grum.cli import main
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from math import isclose
|
||||
|
||||
# from parameterized import parameterized
|
||||
from unittest import mock
|
||||
|
||||
from PyQt5.QtTest import QSignalSpy
|
||||
from PyQt5.QtWidgets import QApplication, QAction, QListWidget
|
||||
|
||||
from grum.cli import main
|
||||
from grum.dictlist.dictlistitem import DictListItem
|
||||
from grum.dictlist import DictList
|
||||
from grum import ctrl_c, theme, assets
|
||||
from grum.mainwin import MainWindow
|
||||
from grum.mdi import MDIArea, MDISubMultiPlot, MDISubPlot
|
||||
from grum.menus import BarMenu
|
||||
from grum.menus.rclickmenu import RClickMenu
|
||||
from grum.plotdesc import PlotDescription
|
||||
from grum.rpc import RPCServerThread
|
||||
|
||||
|
||||
class TestViewUnit(unittest.TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
print("setup")
|
||||
self.app = QApplication(sys.argv)
|
||||
@ -32,6 +30,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
self.mw = MainWindow()
|
||||
self.mw.show()
|
||||
|
||||
|
||||
def tearDown(self) -> None:
|
||||
print("teardown")
|
||||
self.mw.rst.wait_for_stop()
|
||||
@ -40,8 +39,8 @@ class TestViewUnit(unittest.TestCase):
|
||||
del self.mw
|
||||
del self.app
|
||||
|
||||
def test_defaults(self):
|
||||
|
||||
def test_defaults(self):
|
||||
mw = self.mw
|
||||
|
||||
assert mw.windowTitle() == "grum"
|
||||
@ -59,9 +58,9 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
assert isinstance(mw.mdi, MDIArea)
|
||||
|
||||
|
||||
# @parameterized.expand([["Dotted line", "r"], ["Line", "r"], ["Dots", None]])
|
||||
def test_new_plot(self):
|
||||
|
||||
mw = self.mw
|
||||
name = "plot_name"
|
||||
title = "plot_title"
|
||||
@ -124,6 +123,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
print(sine_item.set_alarm.call_args)
|
||||
assert sine_item.set_alarm.call_args[0][0] == False
|
||||
|
||||
|
||||
def test_on_make_new_plot(self):
|
||||
mw = self.mw
|
||||
|
||||
@ -136,6 +136,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
mw.make_subwin.assert_called_once_with(MDISubPlot, args, kwargs)
|
||||
|
||||
|
||||
def test_on_dclick_list_item(self):
|
||||
|
||||
mw = self.mw
|
||||
@ -146,6 +147,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
mw.plot_single_item.assert_called_once_with(item)
|
||||
|
||||
|
||||
def test_on_plot_selected(self):
|
||||
mw = self.mw
|
||||
sine_item = mw.lst.lst.get("sine")
|
||||
@ -167,8 +169,8 @@ class TestViewUnit(unittest.TestCase):
|
||||
mw.on_plot_selected()
|
||||
mw.plot_multiple_items.assert_called_once_with([sine_item, cosine_item])
|
||||
|
||||
def test_plot_single_item(self):
|
||||
|
||||
def test_plot_single_item(self):
|
||||
mw = self.mw
|
||||
sine_item = mw.lst.lst.get("sine")
|
||||
sine_item.set_alarm = mock.MagicMock()
|
||||
@ -181,6 +183,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
MDISubPlot, sine_item.key, sine_item.value
|
||||
)
|
||||
|
||||
|
||||
def test_plot_multiple_items(self):
|
||||
mw = self.mw
|
||||
sine_item = mw.lst.lst.get("sine")
|
||||
@ -196,6 +199,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
mw.activate_or_make_subwin.assert_called_once_with(MDISubMultiPlot, name, descs)
|
||||
|
||||
|
||||
def test_activate_or_make_subwin(self):
|
||||
mw = self.mw
|
||||
sine_item = mw.lst.lst.get("sine")
|
||||
@ -217,6 +221,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
MDISubPlot, cosine_item.key, cosine_item.value
|
||||
)
|
||||
|
||||
|
||||
def test_make_subwin(self):
|
||||
|
||||
mw = self.mw
|
||||
@ -229,3 +234,6 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
assert isinstance(mw.mdi.add.call_args[0][0], MDISubPlot)
|
||||
# mw.mdi.add.assert_called_once_with(sub)
|
||||
|
||||
|
||||
|
||||
|
@ -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()
|
||||
@ -145,6 +154,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
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