Skip to content
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
5 changes: 5 additions & 0 deletions test_bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
from ophyd_async.plan_stubs import ensure_connected

from utilities.utilities import (
assert_with_timeout,
check_block_exists,
load_config_if_not_already_loaded,
set_genie_python_raises_exceptions,
setup_simulated_wiring_tables,
wait_for_iocs_to_be_up,
)

matplotlib.use("qtagg")
Expand All @@ -50,8 +53,10 @@ class TestBluesky(unittest.TestCase):
def setUp(self) -> None:
g.set_instrument(None)
load_config_if_not_already_loaded("bluesky_sys_test")
wait_for_iocs_to_be_up(["SIMPLE", "ISISDAE_01"], 300)
setup_simulated_wiring_tables()
set_genie_python_raises_exceptions(True)
assert_with_timeout(lambda: self.assertTrue(check_block_exists("p3", True)), 60)
g.cset("p3", P3_INIT_VALUE)
g.cset("p5", P5_INIT_VALUE)
set_bluesky_log_levels("DEBUG")
Expand Down
16 changes: 11 additions & 5 deletions utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,18 +510,24 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> None:
return decorator


def check_block_exists(block_name: str) -> bool:
def check_block_exists(block_name: str, check_pv: bool = False) -> bool:
"""
Check that the given block name is in the current blocks.
Check that the given block name is in the current blockserver/configuration
blocks list. Optionally check if the PV for the block also currently exists

Args:
block_name (str): The name of the block to check for
check_pv (bool): Additionally check PV related to block exists

Returns:
bool: true if block is in current blocks, false if not.
bool: true if block exists as per criteria, false if not.
"""
blocks = g.get_blocks()
return block_name in blocks
block_in_list = block_name in g.get_blocks()
return (
block_in_list and genie_api_setup.__api.block_exists(block_name)
if check_pv
else block_in_list
)


def retry_assert(retry_limit: int, func: Callable[[], None], retry_time: float = 1.0) -> None:
Expand Down
Loading