Skip to content

Commit

Permalink
Add test for context race condition (#600)
Browse files Browse the repository at this point in the history
* Add test for context race condition

* Add timeout to wait on connection in test
  • Loading branch information
DominicOram authored and ZohebShaikh committed Nov 14, 2024
1 parent 9b63dc6 commit 5c7d23a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/epics/signal/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
from typing import Any, Literal
from unittest.mock import ANY

import bluesky.plan_stubs as bps
import numpy as np
import numpy.typing as npt
import pytest
from aioca import CANothing, purge_channel_caches
from bluesky.protocols import Reading
from bluesky.run_engine import RunEngine
from event_model import DataKey
from ophyd.signal import EpicsSignal
from typing_extensions import TypedDict

from ophyd_async.core import (
Expand Down Expand Up @@ -917,3 +920,21 @@ async def test_signals_created_for_not_prec_0_float_cannot_use_int(ioc: IOC):
TypeError, match=f"{ioc.protocol}:float_prec_1 has type float not int"
):
await sig.connect()


async def test_can_read_using_ophyd_async_then_ophyd(ioc: IOC):
oa_read = f"{ioc.protocol}://{PV_PREFIX}:{ioc.protocol}:float_prec_1"
ophyd_read = f"{PV_PREFIX}:{ioc.protocol}:float_prec_0"

ophyd_async_sig = epics_signal_rw(float, oa_read)
await ophyd_async_sig.connect()
ophyd_signal = EpicsSignal(ophyd_read)
ophyd_signal.wait_for_connection(timeout=5)

RE = RunEngine()

def my_plan():
yield from bps.rd(ophyd_async_sig)
yield from bps.rd(ophyd_signal)

RE(my_plan())

0 comments on commit 5c7d23a

Please sign in to comment.