From 1b8e25636019f851dd9c517a0e5557861bdceb6c Mon Sep 17 00:00:00 2001 From: stalbe_j Date: Fri, 27 Jan 2023 15:16:51 +0100 Subject: [PATCH 1/6] test:added test_get_asset --- tests/test_assets.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/test_assets.py diff --git a/tests/test_assets.py b/tests/test_assets.py new file mode 100644 index 0000000..a55b791 --- /dev/null +++ b/tests/test_assets.py @@ -0,0 +1,7 @@ +from grum import assets + + +def test_get_asset(): + + ret = assets.get_asset('testname') + assert ret.endswith('grum/grum/assets/testname') From aedeb22884fbac14f7564e745d563cee0801b307 Mon Sep 17 00:00:00 2001 From: stalbe_j Date: Fri, 27 Jan 2023 15:41:09 +0100 Subject: [PATCH 2/6] test: create test_plotdesc --- tests/test_plotdesc.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test_plotdesc.py diff --git a/tests/test_plotdesc.py b/tests/test_plotdesc.py new file mode 100644 index 0000000..e20e3d3 --- /dev/null +++ b/tests/test_plotdesc.py @@ -0,0 +1,32 @@ +from grum.plotdesc import PlotDescription +import pytest + +@pytest.mark.parametrize( + "plot_name, plot_title, plot_xlabel, plot_ylabel, xs,ys", [('plot_name', + 'plot_title', + 'plot_xlabel', + 'plot_ylabel', + [1, 2], + [3, 4]), + ('plot_name', + None, + None, + None, + [], + [])] +) +def test_plot_derscription_init(plot_name, plot_title, plot_xlabel, plot_ylabel, xs, ys): + + if plot_title: + pd = PlotDescription(plot_name, plot_title, + plot_xlabel, plot_ylabel, xs, ys) + else: + pd = PlotDescription(plot_name) + + assert pd.name == plot_name + assert pd.title == plot_title + assert pd.xlabel == plot_xlabel + assert pd.ylabel == plot_ylabel + assert pd.xs == xs + assert pd.ys == ys + From d3a9fd736c3bd1d07196fa2bd67afcd8010a6b72 Mon Sep 17 00:00:00 2001 From: stalbe_j Date: Fri, 27 Jan 2023 15:48:27 +0100 Subject: [PATCH 3/6] test: test_data and test_append --- tests/test_plotdesc.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_plotdesc.py b/tests/test_plotdesc.py index e20e3d3..4722b8e 100644 --- a/tests/test_plotdesc.py +++ b/tests/test_plotdesc.py @@ -30,3 +30,15 @@ def test_plot_derscription_init(plot_name, plot_title, plot_xlabel, plot_ylabel, assert pd.xs == xs assert pd.ys == ys +def test_data(): + pd = PlotDescription('name', xs = [1,2], ys = [3,4]) + + assert pd.data == ([1,2], [3,4]) + +def test_append(): + pd = PlotDescription('name', xs = [1,2], ys = [3,4]) + + pd.append([3,5]) + + assert pd.xs == [1,2,3] + assert pd.ys == [3,4,5] \ No newline at end of file From 43937a0db317d64f3ee93901fdb094f9df2b8479 Mon Sep 17 00:00:00 2001 From: stalbe_j Date: Fri, 27 Jan 2023 16:29:05 +0100 Subject: [PATCH 4/6] test: test_make_plot and test_to_dict --- tests/test_plotdesc.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/test_plotdesc.py b/tests/test_plotdesc.py index 4722b8e..21e5cb3 100644 --- a/tests/test_plotdesc.py +++ b/tests/test_plotdesc.py @@ -1,5 +1,14 @@ from grum.plotdesc import PlotDescription import pytest +import pyqtgraph as pg +from grum.theme import pg_plot_style +from grum.mdi.mdisubplot import MDISubPlot +from grum.mainwin import MainWindow + +import sys +from PyQt5.QtWidgets import QApplication +from grum import theme + @pytest.mark.parametrize( "plot_name, plot_title, plot_xlabel, plot_ylabel, xs,ys", [('plot_name', @@ -41,4 +50,28 @@ def test_append(): pd.append([3,5]) assert pd.xs == [1,2,3] - assert pd.ys == [3,4,5] \ No newline at end of file + assert pd.ys == [3,4,5] + +def test_make_plot(): + + pd = PlotDescription('plot_name', 'plot_title', 'plot_xlabel', 'plot_ylabel', [1,2], [3,4]) + app = QApplication(sys.argv) + theme.apply(app) + mw = MainWindow(add_examples=True) + + mdi_sub = MDISubPlot('mdi', pd) + pw = pg.PlotWidget() + style = pg_plot_style() + + ret = pd.make_plot(pw, style) + + assert isinstance(ret, pg.PlotDataItem) + assert pw.getAxis("left").labelText == 'plot_ylabel' + assert pw.getAxis("bottom").labelText == 'plot_xlabel' + assert pw.getPlotItem().titleLabel.text == 'plot_title' + + +def test_to_dict(): + pd = PlotDescription('plot_name', 'plot_title', 'plot_xlabel', 'plot_ylabel', [1,2], [3,4]) + + assert pd.to_dict() == {'title': 'plot_title', 'xlabel': 'plot_xlabel', 'xs': [1, 2], 'ylabel': 'plot_ylabel', 'ys': [3,4]} \ No newline at end of file From d1fad7251035c195e39c0e60ca5774b3ae0268b2 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 14 Mar 2023 11:19:50 +0100 Subject: [PATCH 5/6] formatting --- tests/test_assets.py | 8 ++-- tests/test_plotdesc.py | 93 +++++++++++++++++++++++------------------- 2 files changed, 55 insertions(+), 46 deletions(-) diff --git a/tests/test_assets.py b/tests/test_assets.py index a55b791..e9fad42 100644 --- a/tests/test_assets.py +++ b/tests/test_assets.py @@ -2,6 +2,8 @@ from grum import assets def test_get_asset(): - - ret = assets.get_asset('testname') - assert ret.endswith('grum/grum/assets/testname') + ret = assets.get_asset("testname") + assert ret.endswith("grum/grum/assets/testname") + + + diff --git a/tests/test_plotdesc.py b/tests/test_plotdesc.py index 21e5cb3..8c811e0 100644 --- a/tests/test_plotdesc.py +++ b/tests/test_plotdesc.py @@ -1,77 +1,84 @@ -from grum.plotdesc import PlotDescription -import pytest -import pyqtgraph as pg -from grum.theme import pg_plot_style -from grum.mdi.mdisubplot import MDISubPlot -from grum.mainwin import MainWindow - import sys +import pytest from PyQt5.QtWidgets import QApplication +import pyqtgraph as pg + from grum import theme +from grum.mainwin import MainWindow +from grum.mdi.mdisubplot import MDISubPlot +from grum.plotdesc import PlotDescription +from grum.theme import pg_plot_style @pytest.mark.parametrize( - "plot_name, plot_title, plot_xlabel, plot_ylabel, xs,ys", [('plot_name', - 'plot_title', - 'plot_xlabel', - 'plot_ylabel', - [1, 2], - [3, 4]), - ('plot_name', - None, - None, - None, - [], - [])] + "plot_name, plot_title, plot_xlabel, plot_ylabel, xs,ys", + [ + ("plot_name", "plot_title", "plot_xlabel", "plot_ylabel", [1, 2], [3, 4]), + ("plot_name", None, None, None, [], []), + ], ) -def test_plot_derscription_init(plot_name, plot_title, plot_xlabel, plot_ylabel, xs, ys): - +def test_plot_derscription_init( + plot_name, plot_title, plot_xlabel, plot_ylabel, xs, ys +): if plot_title: - pd = PlotDescription(plot_name, plot_title, - plot_xlabel, plot_ylabel, xs, ys) - else: + pd = PlotDescription(plot_name, plot_title, plot_xlabel, plot_ylabel, xs, ys) + else: pd = PlotDescription(plot_name) - + assert pd.name == plot_name assert pd.title == plot_title assert pd.xlabel == plot_xlabel assert pd.ylabel == plot_ylabel assert pd.xs == xs assert pd.ys == ys - -def test_data(): - pd = PlotDescription('name', xs = [1,2], ys = [3,4]) - assert pd.data == ([1,2], [3,4]) + +def test_data(): + pd = PlotDescription("name", xs=[1, 2], ys=[3, 4]) + + assert pd.data == ([1, 2], [3, 4]) + def test_append(): - pd = PlotDescription('name', xs = [1,2], ys = [3,4]) + pd = PlotDescription("name", xs=[1, 2], ys=[3, 4]) + pd.append([3, 5]) - pd.append([3,5]) + assert pd.xs == [1, 2, 3] + assert pd.ys == [3, 4, 5] - assert pd.xs == [1,2,3] - assert pd.ys == [3,4,5] def test_make_plot(): - - pd = PlotDescription('plot_name', 'plot_title', 'plot_xlabel', 'plot_ylabel', [1,2], [3,4]) + pd = PlotDescription( + "plot_name", "plot_title", "plot_xlabel", "plot_ylabel", [1, 2], [3, 4] + ) app = QApplication(sys.argv) theme.apply(app) mw = MainWindow(add_examples=True) - mdi_sub = MDISubPlot('mdi', pd) - pw = pg.PlotWidget() + mdi_sub = MDISubPlot("mdi", pd) + pw = pg.PlotWidget() style = pg_plot_style() ret = pd.make_plot(pw, style) - + assert isinstance(ret, pg.PlotDataItem) - assert pw.getAxis("left").labelText == 'plot_ylabel' - assert pw.getAxis("bottom").labelText == 'plot_xlabel' - assert pw.getPlotItem().titleLabel.text == 'plot_title' + assert pw.getAxis("left").labelText == "plot_ylabel" + assert pw.getAxis("bottom").labelText == "plot_xlabel" + assert pw.getPlotItem().titleLabel.text == "plot_title" def test_to_dict(): - pd = PlotDescription('plot_name', 'plot_title', 'plot_xlabel', 'plot_ylabel', [1,2], [3,4]) + pd = PlotDescription( + "plot_name", "plot_title", "plot_xlabel", "plot_ylabel", [1, 2], [3, 4] + ) + + assert pd.to_dict() == { + "title": "plot_title", + "xlabel": "plot_xlabel", + "xs": [1, 2], + "ylabel": "plot_ylabel", + "ys": [3, 4], + } + + - assert pd.to_dict() == {'title': 'plot_title', 'xlabel': 'plot_xlabel', 'xs': [1, 2], 'ylabel': 'plot_ylabel', 'ys': [3,4]} \ No newline at end of file From 946b72e26676f167f03f2fbada5dabd4df88b42d Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 14 Mar 2023 11:28:09 +0100 Subject: [PATCH 6/6] typo --- tests/test_plotdesc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_plotdesc.py b/tests/test_plotdesc.py index 8c811e0..06fd68c 100644 --- a/tests/test_plotdesc.py +++ b/tests/test_plotdesc.py @@ -17,7 +17,7 @@ from grum.theme import pg_plot_style ("plot_name", None, None, None, [], []), ], ) -def test_plot_derscription_init( +def test_plot_description_init( plot_name, plot_title, plot_xlabel, plot_ylabel, xs, ys ): if plot_title: