test:test_on_plot_selected
This commit is contained in:
@ -2,7 +2,7 @@ import unittest
|
||||
import sys
|
||||
|
||||
# import pytest
|
||||
from PyQt5.QtWidgets import QApplication, QAction
|
||||
from PyQt5.QtWidgets import QApplication, QAction, QListWidget
|
||||
from grum.mainwin import MainWindow
|
||||
from grum.dictlist import DictList
|
||||
import mock
|
||||
@ -25,6 +25,7 @@ from math import isclose
|
||||
|
||||
class TestViewUnit(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
print('setup')
|
||||
self.app = QApplication(sys.argv)
|
||||
theme.apply(self.app)
|
||||
ctrl_c.setup(self.app)
|
||||
@ -33,12 +34,7 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
def tearDown(self) -> None:
|
||||
print("teardown")
|
||||
# self.mw.rst.server = []
|
||||
# assert self.mw.rst.server == 1
|
||||
self.mw.rst.server.shutdown()
|
||||
self.mw.rst.server.server_close()
|
||||
# self.mw.rst.disconnect()
|
||||
# self.mw.rst.shutdown()
|
||||
self.mw.rst.wait_for_stop()
|
||||
# self.mw.rst.shutdown()
|
||||
self.app.quit()
|
||||
|
||||
@ -126,4 +122,25 @@ class TestViewUnit(unittest.TestCase):
|
||||
|
||||
mw.on_dclick_list_item(item)
|
||||
|
||||
mw.plot_single_item.assert_called_once_with(item)
|
||||
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")
|
||||
cosine_item = mw.lst.lst.get("cosine")
|
||||
mw.lst.setCurrentItem(sine_item)
|
||||
assert mw.lst.selectedItems()
|
||||
mw.plot_single_item = mock.MagicMock()
|
||||
|
||||
mw.on_plot_selected()
|
||||
mw.plot_single_item.assert_called_once_with(sine_item)
|
||||
|
||||
mw.lst.setSelectionMode(QListWidget.MultiSelection)
|
||||
sine_item.setSelected(True)
|
||||
cosine_item.setSelected(True)
|
||||
|
||||
assert len(mw.lst.selectedItems()) == 2
|
||||
|
||||
mw.plot_multiple_items = mock.MagicMock()
|
||||
mw.on_plot_selected()
|
||||
mw.plot_multiple_items.assert_called_once_with([sine_item, cosine_item])
|
Reference in New Issue
Block a user