-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #788 from jmaruland/define-validate-shape-of-descr…
…iptor Define validate shape of descriptor
- Loading branch information
Showing
2 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from bluesky import RunEngine | ||
from bluesky.plans import count | ||
from ophyd.sim import img | ||
from tiled.client import Context, from_context | ||
from tiled.server.app import build_app | ||
|
||
from ..mongo_normalized import MongoAdapter | ||
|
||
|
||
def test_validate_shape(tmpdir): | ||
# custom_validate_shape will mutate this to show it has been called | ||
shapes = [] | ||
|
||
def custom_validate_shape(key, data, expected_shape): | ||
shapes.append(expected_shape) | ||
return data | ||
|
||
adapter = MongoAdapter.from_mongomock(validate_shape=custom_validate_shape) | ||
|
||
with Context.from_app(build_app(adapter), token_cache=tmpdir) as context: | ||
client = from_context(context) | ||
|
||
def post_document(name, doc): | ||
client.post_document(name, doc) | ||
|
||
RE = RunEngine() | ||
RE.subscribe(post_document) | ||
(uid,) = RE(count([img])) | ||
assert not shapes | ||
client[uid]["primary"]["data"]["img"][:] | ||
assert shapes |