mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
test(end-2-end): rpc end-2-end tests
This commit is contained in:
@ -17,6 +17,7 @@ stages:
|
|||||||
- Formatter
|
- Formatter
|
||||||
- test
|
- test
|
||||||
- AdditionalTests
|
- AdditionalTests
|
||||||
|
- End2End
|
||||||
- Deploy
|
- Deploy
|
||||||
|
|
||||||
formatter:
|
formatter:
|
||||||
@ -120,6 +121,52 @@ tests-3.12:
|
|||||||
image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:3.12
|
image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:3.12
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
|
end-2-end-conda:
|
||||||
|
stage: End2End
|
||||||
|
needs: []
|
||||||
|
image: continuumio/miniconda3
|
||||||
|
allow_failure: false
|
||||||
|
variables:
|
||||||
|
QT_QPA_PLATFORM: "offscreen"
|
||||||
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y libgl1-mesa-glx libegl1-mesa x11-utils libxkbcommon-x11-0 libdbus-1-3
|
||||||
|
- conda config --prepend channels conda-forge
|
||||||
|
- conda config --set channel_priority strict
|
||||||
|
- conda config --set always_yes yes --set changeps1 no
|
||||||
|
- conda create -q -n test-environment python=3.10
|
||||||
|
- conda init bash
|
||||||
|
- source ~/.bashrc
|
||||||
|
- conda activate test-environment
|
||||||
|
|
||||||
|
- git clone --branch $BEC_CORE_BRANCH https://gitlab.psi.ch/bec/bec.git
|
||||||
|
- git clone --branch $OPHYD_DEVICES_BRANCH https://gitlab.psi.ch/bec/ophyd_devices.git
|
||||||
|
- export OHPYD_DEVICES_PATH=$PWD/ophyd_devices
|
||||||
|
|
||||||
|
- cd ./bec
|
||||||
|
- source ./bin/install_bec_dev.sh -t
|
||||||
|
|
||||||
|
- pip install -e ./bec_lib[dev]
|
||||||
|
- pip install -e ./bec_client[dev]
|
||||||
|
- cd ../
|
||||||
|
- pip install -e .[dev]
|
||||||
|
- cd ./tests/end-2-end
|
||||||
|
- redis-server --daemonize yes
|
||||||
|
- pytest --start-servers
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
when: on_failure
|
||||||
|
paths:
|
||||||
|
- ./logs/*.log
|
||||||
|
expire_in: 1 week
|
||||||
|
|
||||||
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "web"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
|
||||||
|
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
|
||||||
|
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "production"'
|
||||||
|
|
||||||
|
|
||||||
semver:
|
semver:
|
||||||
stage: Deploy
|
stage: Deploy
|
||||||
|
60
tests/end-2-end/test_bec_figure_rpc.py
Normal file
60
tests/end-2-end/test_bec_figure_rpc.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from bec_widgets.cli.client import BECFigure, BECImageShow, BECMotorMap, BECWaveform
|
||||||
|
from bec_widgets.cli.server import BECWidgetsCLIServer
|
||||||
|
from bec_widgets.utils import BECDispatcher
|
||||||
|
from bec_widgets.widgets.plots.waveform import Signal, SignalData
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def rpc_server(qtbot, bec_client_lib):
|
||||||
|
dispatcher = BECDispatcher(client=bec_client_lib) # Has to init singleton with fixture client
|
||||||
|
server = BECWidgetsCLIServer(gui_id="id_test")
|
||||||
|
qtbot.addWidget(server.fig)
|
||||||
|
qtbot.waitExposed(server.fig)
|
||||||
|
qtbot.wait(1000) # 1s long to wait until gui is ready
|
||||||
|
yield server
|
||||||
|
server.client.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
def test_rpc_waveform1d_custom_curve(rpc_server, qtbot):
|
||||||
|
fig = BECFigure(rpc_server.gui_id)
|
||||||
|
fig_server = rpc_server.fig
|
||||||
|
|
||||||
|
ax = fig.add_plot()
|
||||||
|
curve = ax.add_curve_custom([1, 2, 3], [1, 2, 3])
|
||||||
|
curve.set_color("red")
|
||||||
|
curve = ax.curves[0]
|
||||||
|
curve.set_color("blue")
|
||||||
|
|
||||||
|
assert len(fig_server.widgets) == 1
|
||||||
|
assert len(fig_server.widgets["widget_1"].curves) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_rpc_plotting_shortcuts(rpc_server, qtbot):
|
||||||
|
fig = BECFigure(rpc_server.gui_id)
|
||||||
|
fig_server = rpc_server.fig
|
||||||
|
|
||||||
|
plt = fig.plot("samx", "bpm4i")
|
||||||
|
im = fig.image("eiger")
|
||||||
|
motor_map = fig.motor_map("samx", "samy")
|
||||||
|
|
||||||
|
# Checking if classes are correctly initialised
|
||||||
|
assert len(fig_server.widgets) == 3
|
||||||
|
assert plt.__class__.__name__ == "BECWaveform"
|
||||||
|
assert plt.__class__ == BECWaveform
|
||||||
|
assert im.__class__.__name__ == "BECImageShow"
|
||||||
|
assert im.__class__ == BECImageShow
|
||||||
|
assert motor_map.__class__.__name__ == "BECMotorMap"
|
||||||
|
assert motor_map.__class__ == BECMotorMap
|
||||||
|
|
||||||
|
# # check if the correct devices are set
|
||||||
|
# plt_curve_config = plt.curves[0].get_config()
|
||||||
|
# assert plt_curve_config["signals"] == {
|
||||||
|
# "source": "scan_segment",
|
||||||
|
# "x": {"name": "samx", "entry": "samx", "unit": None, "modifier": None, "limits": None},
|
||||||
|
# "y": {"name": "bpm4i", "entry": "bpm4i", "unit": None, "modifier": None, "limits": None},
|
||||||
|
# "z": None,
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# im_config = im.get_config()
|
Reference in New Issue
Block a user