From ca2caad46cb939aa83a548ebd60b50bd3d867858 Mon Sep 17 00:00:00 2001 From: stalbe_j Date: Thu, 13 Apr 2023 14:49:04 +0200 Subject: [PATCH] new tests from before --- tests/test_dict_list_widget.py | 27 +++++++++++++++++++++++++++ tests/test_mainwin.py | 16 +++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 tests/test_dict_list_widget.py diff --git a/tests/test_dict_list_widget.py b/tests/test_dict_list_widget.py new file mode 100644 index 0000000..ec77ea2 --- /dev/null +++ b/tests/test_dict_list_widget.py @@ -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) \ No newline at end of file diff --git a/tests/test_mainwin.py b/tests/test_mainwin.py index 6a73af4..567531d 100644 --- a/tests/test_mainwin.py +++ b/tests/test_mainwin.py @@ -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 @@ -167,6 +164,19 @@ class TestMainWin: mw.on_plot_selected() 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