31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
import pytest
|
|
from unittest.mock import MagicMock
|
|
from aare.devices.tell_client import TellClient
|
|
from aare.devices.tell_backend import TellBackend
|
|
|
|
@pytest.fixture
|
|
def mock_backend():
|
|
backend = MagicMock(spec=TellBackend)
|
|
backend.get_state.return_value = "Ready"
|
|
return backend
|
|
|
|
@pytest.fixture
|
|
def mock_beamline():
|
|
return MagicMock()
|
|
|
|
def test_get_state(mock_beamline, mock_backend):
|
|
client = TellClient(mock_beamline, backend=mock_backend)
|
|
assert client.get_state() == "Ready"
|
|
mock_backend.get_state.assert_called()
|
|
|
|
def test_is_in_mount_position_true(mock_beamline, mock_backend):
|
|
mock_backend.eval.return_value = "True"
|
|
client = TellClient(mock_beamline, backend=mock_backend)
|
|
assert client.is_in_mount_position() is True
|
|
mock_backend.eval.assert_called_with("in_mount_position&")
|
|
|
|
def test_is_in_mount_position_false(mock_beamline, mock_backend):
|
|
mock_backend.eval.return_value = "False"
|
|
client = TellClient(mock_beamline, backend=mock_backend)
|
|
assert client.is_in_mount_position() is False
|