71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
"""Module to test prosilica and Basler cam integrations."""
|
|
|
|
import threading
|
|
from unittest import mock
|
|
|
|
import ophyd
|
|
import pytest
|
|
from ophyd_devices.devices.areadetector.cam import AravisDetectorCam, ProsilicaDetectorCam
|
|
from ophyd_devices.devices.areadetector.plugins import ImagePlugin_V35
|
|
from ophyd_devices.tests.utils import MockPV, patch_dual_pvs
|
|
|
|
from debye_bec.devices.cameras.basler_cam import BaslerCam
|
|
from debye_bec.devices.cameras.prosilica_cam import ProsilicaCam
|
|
|
|
# pylint: disable=protected-access
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def mock_basler():
|
|
"""Fixture to mock the camera device."""
|
|
name = "cam"
|
|
prefix = "test:"
|
|
with mock.patch.object(ophyd, "cl") as mock_cl:
|
|
mock_cl.get_pv = MockPV
|
|
mock_cl.thread_class = threading.Thread
|
|
dev = BaslerCam(name=name, prefix=prefix)
|
|
patch_dual_pvs(dev)
|
|
yield dev
|
|
|
|
|
|
def test_basler_init(mock_basler):
|
|
"""Test the initialization of the Basler camera device."""
|
|
assert mock_basler.name == "cam"
|
|
assert mock_basler.prefix == "test:"
|
|
assert isinstance(mock_basler.cam1, AravisDetectorCam)
|
|
assert isinstance(mock_basler.image1, ImagePlugin_V35)
|
|
assert mock_basler._update_frequency == 1
|
|
assert mock_basler._live_mode is False
|
|
assert mock_basler._live_mode_event is None
|
|
assert mock_basler._task_status is None
|
|
assert mock_basler.preview.ndim == 2
|
|
assert mock_basler.preview.num_rotation_90 == 3
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def mock_prosilica():
|
|
"""Fixture to mock the camera device."""
|
|
name = "cam"
|
|
prefix = "test:"
|
|
with mock.patch.object(ophyd, "cl") as mock_cl:
|
|
mock_cl.get_pv = MockPV
|
|
mock_cl.thread_class = threading.Thread
|
|
dev = ProsilicaCam(name=name, prefix=prefix)
|
|
patch_dual_pvs(dev)
|
|
yield dev
|
|
|
|
|
|
def test_prosilica_init(mock_prosilica):
|
|
"""Test the initialization of the Prosilica camera device."""
|
|
assert mock_prosilica.name == "cam"
|
|
assert mock_prosilica.prefix == "test:"
|
|
assert isinstance(mock_prosilica.cam1, ProsilicaDetectorCam)
|
|
assert isinstance(mock_prosilica.image1, ImagePlugin_V35)
|
|
assert mock_prosilica._update_frequency == 1
|
|
assert mock_prosilica._live_mode is False
|
|
assert mock_prosilica._live_mode_event is None
|
|
assert mock_prosilica._task_status is None
|
|
assert mock_prosilica.preview.ndim == 2
|
|
assert mock_prosilica.preview.num_rotation_90 == 3
|