mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
refactor: renamed scanID to scan_id
This commit is contained in:
@ -2,11 +2,10 @@
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
from bec_lib.messages import ScanMessage
|
||||
from bec_lib.connector import MessageObject
|
||||
from bec_lib.messages import ScanMessage
|
||||
|
||||
|
||||
msg = MessageObject(topic="", value=ScanMessage(point_id=0, scanID=0, data={}))
|
||||
msg = MessageObject(topic="", value=ScanMessage(point_id=0, scan_id=0, data={}))
|
||||
|
||||
|
||||
@pytest.fixture(name="consumer")
|
||||
@ -206,7 +205,7 @@ def test_connect_one_slot_multiple_topics_single_callback(bec_dispatcher, consum
|
||||
# Simulate messages being published on each topic
|
||||
for topic in topics:
|
||||
msg_with_topic = MessageObject(
|
||||
topic=topic, value=ScanMessage(point_id=0, scanID=0, data={})
|
||||
topic=topic, value=ScanMessage(point_id=0, scan_id=0, data={})
|
||||
)
|
||||
consumer.register.call_args.kwargs["cb"](msg_with_topic)
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
# pylint: disable = no-name-in-module,missing-class-docstring, missing-module-docstring
|
||||
import os
|
||||
import yaml
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
import yaml
|
||||
|
||||
from bec_widgets.widgets import BECMonitor
|
||||
|
||||
@ -126,12 +126,7 @@ def test_on_config_update(monitor, config_initial, config_update):
|
||||
@pytest.mark.parametrize(
|
||||
"config_name, expected_num_columns, expected_plot_names, expected_coordinates",
|
||||
[
|
||||
(
|
||||
"config_device",
|
||||
1,
|
||||
["BPM4i plots vs samx", "Gauss plots vs samx"],
|
||||
[(0, 0), (1, 0)],
|
||||
),
|
||||
("config_device", 1, ["BPM4i plots vs samx", "Gauss plots vs samx"], [(0, 0), (1, 0)]),
|
||||
(
|
||||
"config_scan",
|
||||
3,
|
||||
@ -186,7 +181,7 @@ msg_1 = {
|
||||
"gauss_adc1": {"gauss_adc1": {"value": 8}},
|
||||
"gauss_adc2": {"gauss_adc2": {"value": 9}},
|
||||
},
|
||||
"scanID": 1,
|
||||
"scan_id": 1,
|
||||
}
|
||||
metadata_grid = {"scan_name": "grid_scan"}
|
||||
metadata_line = {"scan_name": "line_scan"}
|
||||
@ -195,7 +190,7 @@ metadata_line = {"scan_name": "line_scan"}
|
||||
@pytest.mark.parametrize(
|
||||
"config_name, msg, metadata, expected_data",
|
||||
[
|
||||
# case: msg does not have 'scanID'
|
||||
# case: msg does not have 'scan_id'
|
||||
(
|
||||
"config_device",
|
||||
{"data": {}},
|
||||
|
@ -1,17 +1,14 @@
|
||||
# pylint: disable=missing-module-docstring, missing-function-docstring
|
||||
from collections import defaultdict
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
from qtpy import QtGui
|
||||
|
||||
from bec_widgets.widgets import BECMonitor2DScatter
|
||||
|
||||
CONFIG_DEFAULT = {
|
||||
"plot_settings": {
|
||||
"colormap": "CET-L4",
|
||||
"num_columns": 1,
|
||||
},
|
||||
"plot_settings": {"colormap": "CET-L4", "num_columns": 1},
|
||||
"waveform2D": [
|
||||
{
|
||||
"plot_name": "Waveform 2D Scatter (1)",
|
||||
@ -37,10 +34,7 @@ CONFIG_DEFAULT = {
|
||||
}
|
||||
|
||||
CONFIG_ONE_PLOT = {
|
||||
"plot_settings": {
|
||||
"colormap": "CET-L4",
|
||||
"num_columns": 1,
|
||||
},
|
||||
"plot_settings": {"colormap": "CET-L4", "num_columns": 1},
|
||||
"waveform2D": [
|
||||
{
|
||||
"plot_name": "Waveform 2D Scatter (1)",
|
||||
@ -51,7 +45,7 @@ CONFIG_ONE_PLOT = {
|
||||
"y": [{"name": "aptry", "entry": "aptry"}],
|
||||
"z": [{"name": "gauss_bpm", "entry": "gauss_bpm"}],
|
||||
},
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
@ -65,13 +59,7 @@ def monitor_2Dscatter(qtbot):
|
||||
yield widget
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config, number_of_plots",
|
||||
[
|
||||
(CONFIG_DEFAULT, 2),
|
||||
(CONFIG_ONE_PLOT, 1),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("config, number_of_plots", [(CONFIG_DEFAULT, 2), (CONFIG_ONE_PLOT, 1)])
|
||||
def test_initialization(monitor_2Dscatter, config, number_of_plots):
|
||||
config_load = config
|
||||
monitor_2Dscatter.on_config_update(config_load)
|
||||
@ -81,13 +69,7 @@ def test_initialization(monitor_2Dscatter, config, number_of_plots):
|
||||
assert len(monitor_2Dscatter.plot_data) == number_of_plots
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config ",
|
||||
[
|
||||
(CONFIG_DEFAULT),
|
||||
(CONFIG_ONE_PLOT),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("config ", [(CONFIG_DEFAULT), (CONFIG_ONE_PLOT)])
|
||||
def test_database_initialization(monitor_2Dscatter, config):
|
||||
monitor_2Dscatter.on_config_update(config)
|
||||
# Check if the database is a defaultdict
|
||||
@ -108,13 +90,7 @@ def test_database_initialization(monitor_2Dscatter, config):
|
||||
assert isinstance(monitor_2Dscatter.database[plot_name][axis][signal_name], list)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config ",
|
||||
[
|
||||
(CONFIG_DEFAULT),
|
||||
(CONFIG_ONE_PLOT),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("config ", [(CONFIG_DEFAULT), (CONFIG_ONE_PLOT)])
|
||||
def test_ui_initialization(monitor_2Dscatter, config):
|
||||
monitor_2Dscatter.on_config_update(config)
|
||||
assert len(monitor_2Dscatter.plots) == len(config["waveform2D"])
|
||||
@ -133,7 +109,7 @@ def simulate_scan_data(monitor, x_value, y_value, z_value):
|
||||
"samy": {"samy": {"value": y_value}},
|
||||
"gauss_bpm": {"gauss_bpm": {"value": z_value}},
|
||||
},
|
||||
"scanID": 1,
|
||||
"scan_id": 1,
|
||||
}
|
||||
monitor.on_scan_segment(msg, {})
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
# pylint: disable = no-name-in-module,missing-class-docstring, missing-module-docstring
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from bec_widgets.validation.monitor_config_validator import (
|
||||
MonitorConfigValidator,
|
||||
Signal,
|
||||
AxisSignal,
|
||||
MonitorConfigValidator,
|
||||
PlotConfig,
|
||||
Signal,
|
||||
)
|
||||
|
||||
from .test_bec_monitor import mocked_client
|
||||
@ -84,7 +85,7 @@ def test_plot_config_no_source_type_provided(setup_devices):
|
||||
def test_plot_config_history_source_type(setup_devices):
|
||||
history_source = {
|
||||
"type": "history",
|
||||
"scanID": "valid_scan_id",
|
||||
"scan_id": "valid_scan_id",
|
||||
"signals": {"x": [{"name": "samx"}], "y": [{"name": "samx"}]},
|
||||
}
|
||||
|
||||
@ -92,7 +93,7 @@ def test_plot_config_history_source_type(setup_devices):
|
||||
|
||||
assert len(plot_config.sources) == 1
|
||||
assert plot_config.sources[0].type == "history"
|
||||
assert plot_config.sources[0].scanID == "valid_scan_id"
|
||||
assert plot_config.sources[0].scan_id == "valid_scan_id"
|
||||
|
||||
|
||||
def test_plot_config_redis_source_type(setup_devices):
|
||||
|
@ -4,7 +4,8 @@ from unittest.mock import MagicMock
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from bec_widgets.widgets.plots.waveform1d import SignalData, Signal, CurveConfig
|
||||
from bec_widgets.widgets.plots.waveform1d import CurveConfig, Signal, SignalData
|
||||
|
||||
from .client_mocks import mocked_client
|
||||
from .test_bec_figure import bec_figure
|
||||
|
||||
@ -365,7 +366,7 @@ def test_scan_update(bec_figure, qtbot):
|
||||
"gauss_adc1": {"gauss_adc1": {"value": 8}},
|
||||
"gauss_adc2": {"gauss_adc2": {"value": 9}},
|
||||
},
|
||||
"scanID": 1,
|
||||
"scan_id": 1,
|
||||
}
|
||||
# Mock scan_storage.find_scan_by_ID
|
||||
mock_scan_data_waveform = MagicMock()
|
||||
@ -400,8 +401,8 @@ def test_scan_history_with_val_access(bec_figure, qtbot):
|
||||
mock_scan_storage.find_scan_by_ID.return_value = MagicMock(data=mock_scan_data)
|
||||
w1.queue.scan_storage = mock_scan_storage
|
||||
|
||||
fake_scanID = "fake_scanID"
|
||||
w1.scan_history(scanID=fake_scanID)
|
||||
fake_scan_id = "fake_scan_id"
|
||||
w1.scan_history(scan_id=fake_scan_id)
|
||||
|
||||
qtbot.wait(500)
|
||||
|
||||
|
Reference in New Issue
Block a user