Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing kwargs to make_all_devices for dodal modules #304

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/blueapi/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def plan_2(...) -> MsgGenerator:
def with_device_module(self, module: ModuleType) -> None:
self.with_dodal_module(module)

def with_dodal_module(self, module: ModuleType) -> None:
def with_dodal_module(self, module: ModuleType, **kwargs) -> None:
from dodal.utils import make_all_devices

for device in make_all_devices(module).values():
for device in make_all_devices(module, **kwargs).values():
self.device(device)

def plan(self, plan: PlanGenerator) -> PlanGenerator:
Expand Down
16 changes: 16 additions & 0 deletions tests/core/test_context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import Dict, List, Type, Union
from unittest.mock import patch

import pytest
from bluesky.protocols import Descriptor, Movable, Readable, Reading, SyncOrAsync
Expand Down Expand Up @@ -171,6 +172,21 @@ def test_add_devices_from_module(empty_context: BlueskyContext) -> None:
} == empty_context.devices.keys()


def test_extra_kwargs_in_with_dodal_module_passed_to_make_all_devices(
empty_context: BlueskyContext,
) -> None:
import tests.core.fake_device_module as device_module

with patch("dodal.utils.make_all_devices") as mock_make_all_devices:
empty_context.with_dodal_module(
device_module, some_argument=1, another_argument="two"
)

mock_make_all_devices.assert_called_once_with(
device_module, some_argument=1, another_argument="two"
)


@pytest.mark.parametrize(
"addr", ["sim", "sim_det", "sim.setpoint", ["sim"], ["sim", "setpoint"]]
)
Expand Down