Skip to content

Commit

Permalink
Fixed tests so they pass with pytest-asyncio==0.25.2
Browse files Browse the repository at this point in the history
  • Loading branch information
canismarko committed Jan 12, 2025
1 parent fcb2653 commit 564e4dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
19 changes: 10 additions & 9 deletions src/firefly/tests/test_controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import AsyncMock, MagicMock
from unittest.mock import MagicMock

import pytest
from bluesky_queueserver_api.zmq.aio import REManagerAPI
from ophyd import Device
from ophyd.sim import make_fake_device
from ophydregistry import Registry
Expand All @@ -16,16 +17,16 @@
async def controller(qapp):
controller = FireflyController()
await controller.setup_instrument(load_instrument=False)
return controller
yield controller


@pytest.fixture()
def ffapp():
return MagicMock()
async def api():
_api = REManagerAPI()
return _api


def test_prepare_queue_client(controller):
api = MagicMock()
def test_prepare_queue_client(controller, api):
controller.prepare_queue_client(api=api)
assert isinstance(controller._queue_client, QueueClient)

Expand Down Expand Up @@ -107,7 +108,7 @@ async def test_load_instrument_registry(controller, qtbot, monkeypatch):
"""Check that the instrument registry gets created."""
assert isinstance(controller.registry, Registry)
# Mock the underlying haven instrument loader
loader = AsyncMock()
loader = MagicMock()
monkeypatch.setattr(firefly.controller.beamline, "load", loader)
monkeypatch.setattr(controller, "prepare_queue_client", MagicMock())
# Reload the devices and see if the registry is changed
Expand All @@ -132,12 +133,12 @@ def test_queue_stopped(controller):
assert not controller.actions.queue_controls["stop_queue"].isChecked()


def test_autostart_changed(controller, qtbot):
async def test_autostart_changed(controller, qtbot, api):
"""Does the action respond to changes in the queue autostart
status?
"""
client = controller.prepare_queue_client(api=MagicMock())
client = controller.prepare_queue_client(api=api)
autostart_action = controller.actions.queue_settings["autostart"]
autostart_action.setChecked(True)
assert autostart_action.isChecked()
Expand Down
5 changes: 2 additions & 3 deletions src/firefly/tests/test_line_scan_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ async def motors(sim_registry, sync_motors):

@pytest.fixture()
async def display(qtbot, sim_registry, sync_motors, motors, dxp, ion_chamber):
print(motors[0].name)
display = LineScanDisplay()
qtbot.addWidget(display)
await display.update_devices(sim_registry)
Expand Down Expand Up @@ -125,7 +124,7 @@ async def test_line_scan_plan_queued(display, monkeypatch, qtbot):

# time is calculated when the selection is changed
display.ui.detectors_list.selected_detectors = mock.MagicMock(
return_value=["vortex_me4", "I0"]
return_value=["vortex_me4", "I00"]
)

# set up meta data
Expand All @@ -135,7 +134,7 @@ async def test_line_scan_plan_queued(display, monkeypatch, qtbot):

expected_item = BPlan(
"rel_scan",
["vortex_me4", "I0"],
["vortex_me4", "I00"],
"async_motor_1",
1.0,
111.0,
Expand Down

0 comments on commit 564e4dc

Please sign in to comment.