mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
refactor: rename line_plot to basic_plot
This commit is contained in:
@ -3,14 +3,14 @@ from unittest import mock
|
||||
import numpy as np
|
||||
from pytestqt import qtbot
|
||||
|
||||
from bec_widgets import line_plot
|
||||
from bec_widgets import basic_plot
|
||||
|
||||
|
||||
def test_line_plot_emits_no_signal(qtbot):
|
||||
def test_basic_plot_emits_no_signal(qtbot):
|
||||
"""Test LinePlot emits no signal when only one data entry is present."""
|
||||
|
||||
y_value_list = ["y1", "y2"]
|
||||
plot = line_plot.BasicPlot(y_value_list=y_value_list)
|
||||
plot = basic_plot.BasicPlot(y_value_list=y_value_list)
|
||||
data = {
|
||||
"data": {
|
||||
"x": {"x": {"value": 1}},
|
||||
@ -19,17 +19,17 @@ def test_line_plot_emits_no_signal(qtbot):
|
||||
}
|
||||
}
|
||||
metadata = {"scanID": "test", "scan_number": 1, "scan_report_devices": ["x"]}
|
||||
with mock.patch("bec_widgets.line_plot.client") as mock_client:
|
||||
with mock.patch("bec_widgets.basic_plot.client") as mock_client:
|
||||
with mock.patch.object(plot, "update_signal") as mock_update_signal:
|
||||
plot.on_scan_segment(data=data, metadata=metadata)
|
||||
mock_update_signal.emit.assert_not_called()
|
||||
|
||||
|
||||
def test_line_plot_emits_signal(qtbot):
|
||||
def test_basic_plot_emits_signal(qtbot):
|
||||
"""Test LinePlot emits signal."""
|
||||
|
||||
y_value_list = ["y1", "y2"]
|
||||
plot = line_plot.BasicPlot(y_value_list=y_value_list)
|
||||
plot = basic_plot.BasicPlot(y_value_list=y_value_list)
|
||||
data = {
|
||||
"data": {
|
||||
"x": {"x": {"value": 1}},
|
||||
@ -39,7 +39,7 @@ def test_line_plot_emits_signal(qtbot):
|
||||
}
|
||||
plotter_data_y = [[1, 1], [3, 3]]
|
||||
metadata = {"scanID": "test", "scan_number": 1, "scan_report_devices": ["x"]}
|
||||
with mock.patch("bec_widgets.line_plot.client") as mock_client:
|
||||
with mock.patch("bec_widgets.basic_plot.client") as mock_client:
|
||||
# mock_client.device_manager.devices.keys.return_value = ["y1"]
|
||||
with mock.patch.object(plot, "update_signal") as mock_update_signal:
|
||||
mock_update_signal.emit()
|
||||
@ -50,11 +50,11 @@ def test_line_plot_emits_signal(qtbot):
|
||||
# assert plot.plotter_data_y == plotter_data_y
|
||||
|
||||
|
||||
def test_line_plot_raise_warning_wrong_signal_request(qtbot):
|
||||
def test_basic_plot_raise_warning_wrong_signal_request(qtbot):
|
||||
"""Test LinePlot raises warning and skips signal when entry not present in data."""
|
||||
|
||||
y_value_list = ["y1", "y22"]
|
||||
plot = line_plot.BasicPlot(y_value_list=y_value_list)
|
||||
plot = basic_plot.BasicPlot(y_value_list=y_value_list)
|
||||
data = {
|
||||
"data": {
|
||||
"x": {"x": {"value": [1, 2, 3, 4, 5]}},
|
||||
@ -63,7 +63,7 @@ def test_line_plot_raise_warning_wrong_signal_request(qtbot):
|
||||
}
|
||||
}
|
||||
metadata = {"scanID": "test", "scan_number": 1, "scan_report_devices": ["x"]}
|
||||
with mock.patch("bec_widgets.line_plot.client") as mock_client:
|
||||
with mock.patch("bec_widgets.basic_plot.client") as mock_client:
|
||||
# TODO fix mock_client
|
||||
mock_dict = {"y1": [1, 2]}
|
||||
mock_client.device_manager.devices.__contains__.side_effect = mock_dict.__contains__
|
||||
@ -75,11 +75,11 @@ def test_line_plot_raise_warning_wrong_signal_request(qtbot):
|
||||
assert plot.y_value_list == ["y1"]
|
||||
|
||||
|
||||
# def test_line_plot_update(qtbot):
|
||||
# def test_basic_plot_update(qtbot):
|
||||
# """Test LinePlot update."""
|
||||
|
||||
# y_value_list = ["y1", "y2"]
|
||||
# plot = line_plot.BasicPlot(y_value_list=y_value_list)
|
||||
# plot = basic_plot.BasicPlot(y_value_list=y_value_list)
|
||||
# plot.label_bottom = "x"
|
||||
# plot.label_left = f"{', '.join(y_value_list)}"
|
||||
# plot.plotter_data_x = [1, 2, 3, 4, 5]
|
||||
@ -92,11 +92,11 @@ def test_line_plot_raise_warning_wrong_signal_request(qtbot):
|
||||
|
||||
|
||||
# # TODO Outputting the wrong data, e.g. motor is not in list of devices
|
||||
# def test_line_plot_update(qtbot):
|
||||
# def test_basic_plot_update(qtbot):
|
||||
# """Test LinePlot update."""
|
||||
|
||||
# y_value_list = ["y1", "y2"]
|
||||
# plot = line_plot.BasicPlot(y_value_list=y_value_list)
|
||||
# plot = basic_plot.BasicPlot(y_value_list=y_value_list)
|
||||
# plot.label_bottom = "x"
|
||||
# plot.label_left = f"{', '.join(y_value_list)}"
|
||||
# plot.plotter_data_x = [1, 2, 3, 4, 5]
|
||||
@ -108,11 +108,11 @@ def test_line_plot_raise_warning_wrong_signal_request(qtbot):
|
||||
# assert all(plot.curves[1].getData()[1] == np.array([3, 4, 5, 6, 7]))
|
||||
|
||||
|
||||
# def test_line_plot_mouse_moved(qtbot):
|
||||
# def test_basic_plot_mouse_moved(qtbot):
|
||||
# """Test LinePlot mouse_moved."""
|
||||
|
||||
# y_value_list = ["y1", "y2"]
|
||||
# plot = line_plot.BasicPlot(y_value_list=y_value_list)
|
||||
# plot = basic_plot.BasicPlot(y_value_list=y_value_list)
|
||||
# plot.plotter_data_x = [1, 2, 3, 4, 5]
|
||||
# plot.plotter_data_y = [[1, 2, 3, 4, 5], [3, 4, 5, 6, 7]]
|
||||
# plot.precision = 3
|
Reference in New Issue
Block a user