|
@pytest.mark.xfail(reason="Possibly broken by predeclare, need investigation") |
|
def test_config_data(db, RE, hw): |
|
# simple case: one Event Descriptor, one stream |
|
RE.subscribe(db.insert) |
|
from ophyd import Device, sim, Component as C |
|
|
|
class SynWithConfig(Device): |
|
x = C(sim.Signal, value=0) |
|
y = C(sim.Signal, value=2) |
|
z = C(sim.Signal, value=3) |
|
|
|
det = SynWithConfig(name='det') |
|
det.x.name = 'x' |
|
det.y.name = 'y' |
|
det.z.name = 'z' |
|
det.read_attrs = ['x'] |
|
det.configuration_attrs = ['y', 'z'] |
|
|
|
uid, = get_uids(RE(count([det]))) |
|
h = db[uid] |
|
actual = h.config_data('det') |
|
expected = {'primary': [{'y': 2, 'z': 3}]} |
|
assert actual == expected |
|
|
|
# generate two Event Descriptors in the primary stream |
|
@run_decorator() |
|
def plan(): |
|
# working around 'yield from' here which breaks py2 |
|
for msg in configure(det, {'z': 3}): # no-op |
|
yield msg |
|
for msg in trigger_and_read([det]): |
|
yield msg |
|
# changing the config after a read generates a new Event Descriptor |
|
for msg in configure(det, {'z': 4}): |
|
yield msg |
|
for msg in trigger_and_read([det]): |
|
yield msg |
|
|
|
uid, = get_uids(RE(plan())) |
|
h = db[uid] |
|
actual = h.config_data('det') |
|
expected = {'primary': [{'y': 2, 'z': 3}, {'y': 2, 'z': 4}]} |
|
assert actual == expected |
|
|
|
# generate two streams, primary and baseline -- one Event Descriptor each |
|
uid, = get_uids(RE(baseline_wrapper(count([det]), [det]))) |
|
h = db[uid] |
|
actual = h.config_data('det') |
|
expected = {'primary': [{'y': 2, 'z': 4}], |
|
'baseline': [{'y': 2, 'z': 4}]} |
|
assert actual == expected |
|
|
|
# https://github.com/bluesky/databroker/issues/745 |
|
if hasattr(db, 'v2'): |
|
db.v2[uid]['primary']['config']['det']['y'][:] |
|
db.v2[uid]['primary']['config']['det']['z'][:] |
I added an
xfailto this test in #772databroker/databroker/tests/test_broker.py
Lines 706 to 761 in 9959b39
This failed around the same time as other tests failed due to the change to bluesky that introduced pre-declaring streams by default. I suspect this may be related to that, but have not closely investigated.