new tests from before

This commit is contained in:
stalbe_j
2023-04-13 14:49:04 +02:00
parent b13b91e55b
commit ca2caad46c
2 changed files with 40 additions and 3 deletions

View File

@ -0,0 +1,27 @@
from grum.dictlist.dictlistwidget import DictListWidget
from grum.menus.rclickmenu import RClickMenu
class DictListWidgetMock(DictListWidget):
def __init__(self) -> None:
self.items = {}
self.nkeep = None
def get_DictListWidgetMock():
return DictListWidgetMock()
# def test_defaults():
# dlw = get_DictListWidgetMock()
# assert dlw.items == {}
# assert dlw.nkeep == None
# def test_add_menu():
# dlw = get_DictListWidgetMock()
# dlw._add_menu()
# assert dlw.menu == RClickMenu(dlw)

View File

@ -21,7 +21,6 @@ from grum.rpc import RPCServerThread
class TestMainWin:
def setup_method(self):
print("setup")
self.app = QApplication(sys.argv)
theme.apply(self.app)
# ctrl_c.setup(self.app)
@ -30,10 +29,8 @@ class TestMainWin:
def teardown_method(self):
print("teardown")
self.mw.rst.wait_for_stop()
self.app.quit()
print("app quit called")
del self.mw
del self.app
@ -168,6 +165,19 @@ class TestMainWin:
mw.plot_multiple_items.assert_called_once_with([sine_item, cosine_item])
def test_on_sort_by_name(self):
mw = self.mw
mw.lst = DictList()
mw.new_plot("bb", {})
mw.new_plot("dd", {})
mw.new_plot("aa", {})
mw.new_plot("cc", {})
assert mw.lst.lst.items == 111
assert [key for key in mw.lst.lst.items.keys()] == ['bb', 'dd', 'aa', 'cc']
mw.on_sort_by_name()
assert mw.lst.lst.items == 111
def test_plot_single_item(self):
mw = self.mw
sine_item = mw.lst.lst.get("sine")