0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

test(test_plot_base): BECPlotBase tests added

This commit is contained in:
wyzula-jan
2024-02-23 13:37:25 +01:00
parent f668eb8b9b
commit 826a5e9874
2 changed files with 102 additions and 13 deletions

61
tests/test_plot_base.py Normal file
View File

@ -0,0 +1,61 @@
import pytest
from .client_mocks import mocked_client
from .test_bec_figure import bec_figure
def test_init_plot_base(bec_figure):
plot_base = bec_figure.add_widget(widget_type="PlotBase", widget_id="test_plot")
assert plot_base is not None
assert plot_base.config.widget_class == "BECPlotBase"
assert plot_base.config.gui_id == "test_plot"
def test_plot_base_axes_by_separate_methods(bec_figure):
plot_base = bec_figure.add_widget(widget_type="PlotBase", widget_id="test_plot")
plot_base.set_title("Test Title")
plot_base.set_x_label("Test x Label")
plot_base.set_y_label("Test y Label")
plot_base.set_x_lim(1, 100)
plot_base.set_y_lim(5, 500)
plot_base.set_grid(True, True)
plot_base.set_x_scale("log")
plot_base.set_y_scale("log")
assert plot_base.titleLabel.text == "Test Title"
assert plot_base.config.axis.title == "Test Title"
assert plot_base.getAxis("bottom").labelText == "Test x Label"
assert plot_base.config.axis.x_label == "Test x Label"
assert plot_base.getAxis("left").labelText == "Test y Label"
assert plot_base.config.axis.y_label == "Test y Label"
assert plot_base.config.axis.x_lim == (1, 100)
assert plot_base.config.axis.y_lim == (5, 500)
assert plot_base.ctrl.xGridCheck.isChecked() == True
assert plot_base.ctrl.yGridCheck.isChecked() == True
assert plot_base.ctrl.logXCheck.isChecked() == True
assert plot_base.ctrl.logYCheck.isChecked() == True
def test_plot_base_axes_added_by_kwargs(bec_figure):
plot_base = bec_figure.add_widget(widget_type="PlotBase", widget_id="test_plot")
plot_base.set(
title="Test Title",
x_label="Test x Label",
y_label="Test y Label",
x_lim=(1, 100),
y_lim=(5, 500),
x_scale="log",
y_scale="log",
)
assert plot_base.titleLabel.text == "Test Title"
assert plot_base.config.axis.title == "Test Title"
assert plot_base.getAxis("bottom").labelText == "Test x Label"
assert plot_base.config.axis.x_label == "Test x Label"
assert plot_base.getAxis("left").labelText == "Test y Label"
assert plot_base.config.axis.y_label == "Test y Label"
assert plot_base.config.axis.x_lim == (1, 100)
assert plot_base.config.axis.y_lim == (5, 500)
assert plot_base.ctrl.logXCheck.isChecked() == True
assert plot_base.ctrl.logYCheck.isChecked() == True