CI / lint (pull_request) Successful in 1m0s
CI / test (3.12) (pull_request) Successful in 1m55s
CI / test (3.13) (pull_request) Successful in 1m49s
CI / test (3.14) (pull_request) Successful in 1m56s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 1m14s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 1m11s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 1m24s
CI / test-with-coverage (pull_request) Successful in 1m34s
CI / coverage-analysis (pull_request) Failing after 3s
Docs build and publish / docker (push) Successful in 2s
CI / coverage-analysis (push) Canceled after 0s
CI / lint (push) Canceled after 1m11s
Build and Publish / release (push) Successful in 1m3s
CI / test (3.12) (push) Canceled after 1m12s
CI / test (3.14) (push) Canceled after 1m13s
CI / test-with-beamline-plugins (pxi_bec) (push) Canceled after 1m9s
CI / test-with-beamline-plugins (pxii_bec) (push) Canceled after 1m9s
CI / test-with-coverage (push) Canceled after 1m10s
CI / test-with-beamline-plugins (pxiii_bec) (push) Canceled after 1m11s
CI / test (3.13) (push) Canceled after 1m16s
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
from PySide6.QtWidgets import QMessageBox
|
|
|
|
from aare.gui.widgets.message_box import (
|
|
experiment_hutch_shutter_check,
|
|
reply_box,
|
|
ring_current_low_check,
|
|
)
|
|
|
|
|
|
def test_reply_box(qtbot):
|
|
parent = MagicMock()
|
|
with patch("PySide6.QtWidgets.QMessageBox.question") as mock_question:
|
|
mock_question.return_value = QMessageBox.StandardButton.Yes
|
|
res = reply_box(parent, "Title", "Message")
|
|
assert res == QMessageBox.StandardButton.Yes
|
|
mock_question.assert_called_once()
|
|
|
|
|
|
@pytest.mark.timeout(10)
|
|
def test_ring_current_low_check_ok(qtbot):
|
|
# Should return True immediately if current is high enough
|
|
assert ring_current_low_check(None, 361.0) is True
|
|
|
|
|
|
def test_ring_current_low_check_low_yes(qtbot):
|
|
with patch("aare.gui.widgets.message_box.reply_box") as mock_reply:
|
|
mock_reply.return_value = QMessageBox.StandardButton.Yes
|
|
assert ring_current_low_check(None, 50.0) is True
|
|
mock_reply.assert_called_once()
|
|
|
|
|
|
def test_ring_current_low_check_low_no(qtbot):
|
|
with patch("aare.gui.widgets.message_box.reply_box") as mock_reply:
|
|
mock_reply.return_value = QMessageBox.StandardButton.No
|
|
assert ring_current_low_check(None, 50.0) is False
|
|
|
|
|
|
def test_experiment_hutch_shutter_check_open(qtbot):
|
|
assert experiment_hutch_shutter_check(None, True) is True
|
|
|
|
|
|
def test_experiment_hutch_shutter_check_closed_yes(qtbot):
|
|
with patch("aare.gui.widgets.message_box.reply_box") as mock_reply:
|
|
mock_reply.return_value = QMessageBox.StandardButton.Yes
|
|
assert experiment_hutch_shutter_check(None, False) is True
|