Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
untzag committed Aug 14, 2023
1 parent e3c6b64 commit 7c1eef1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
29 changes: 26 additions & 3 deletions tests/property/test_property.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import time
import yaqc
import happi
import pathlib
import appdirs
import yaqc_bluesky
from yaqd_core import testing
import numpy as np
import tempfile
import bluesky
from bluesky import plans as bsp


__here__ = pathlib.Path(__file__).parent
Expand All @@ -22,5 +23,27 @@ def test_property():
assert np.isclose(device.position, 0.222)


if __name__ == "__main__":
test_property()
@testing.run_daemon_entry_point(
"fake-has-transformed-position", config=__here__ / "transformed-position-config.toml"
)
def test_count():
RE = bluesky.RunEngine()
d = yaqc_bluesky.Device(38999)
RE(bsp.count([d.native_destination, d.native_position, d.native_reference_position], num=5))


@testing.run_daemon_entry_point(
"fake-has-transformed-position", config=__here__ / "transformed-position-config.toml"
)
def test_scan():
RE = bluesky.RunEngine()
d = yaqc_bluesky.Device(38999)
RE(
bsp.scan(
[d.native_destination, d.native_position, d.native_reference_position],
d.native_destination,
0,
1,
15,
)
)
2 changes: 2 additions & 0 deletions tests/property/transformed-position-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[optimus]
port = 38999
1 change: 1 addition & 0 deletions yaqc_bluesky/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self, yaq_client, *, name=None):
if key in ["destination", "position"]:
continue
if prop.type not in ["double"]:

continue
self.children.append(PropertyDevice(self, key))
if not hasattr(self, key): # don't overwrite please
Expand Down
6 changes: 3 additions & 3 deletions yaqc_bluesky/_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def set(self, value) -> Status:

def describe(self) -> dict:
out = dict()
out[f"{self.parent.name}_{self.name}_readback"] = {"dtype": "number", "shape": []}
out[f"{self.parent.name}_{self.name}_readback"] = {"dtype": "number", "shape": [], "source": f"yaq:{self.parent.yaq_name}"
}
if self._yaq_property._property["getter"]:
out[f"{self.parent.name}_{self.name}_setpoint"] = {"dtype": "number", "shape": []}
out[f"{self.parent.name}_{self.name}_setpoint"] = {"dtype": "number", "shape": [], "source": f"yaq:{self.parent.yaq_name}"}
return out

def read(self) -> dict:
Expand All @@ -43,4 +44,3 @@ def read(self) -> dict:
if self._yaq_property._property["getter"]:
out[f"{self.parent.name}_{self.name}_setpoint"] = {"value": self._setpoint, "timestamp": ts}
return out

0 comments on commit 7c1eef1

Please sign in to comment.