refactor: cleanup and unifying galil classes

This commit is contained in:
2023-11-08 14:01:20 +01:00
parent 89cf412551
commit 981b877038
10 changed files with 242 additions and 532 deletions

30
tests/test_controller.py Normal file
View File

@ -0,0 +1,30 @@
from unittest import mock
from ophyd_devices.utils.controller import Controller
def test_controller_off():
controller = Controller(socket_cls=mock.MagicMock(), socket_host="dummy", socket_port=123)
controller.on()
with mock.patch.object(controller.sock, "close") as mock_close:
controller.off()
assert controller.sock is None
assert controller.connected is False
mock_close.assert_called_once()
# make sure it is indempotent
controller.off()
def test_controller_on():
socket_cls = mock.MagicMock()
Controller._controller_instances = {}
controller = Controller(socket_cls=socket_cls, socket_host="dummy", socket_port=123)
controller.on()
assert controller.sock is not None
assert controller.connected is True
socket_cls().open.assert_called_once()
# make sure it is indempotent
controller.on()
socket_cls().open.assert_called_once()