Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write docs on how to do testing #206

Closed
coretl opened this issue Apr 15, 2024 · 1 comment · Fixed by #226
Closed

Write docs on how to do testing #206

coretl opened this issue Apr 15, 2024 · 1 comment · Fixed by #226
Assignees
Labels
good first issue Good for newcomers hackathon Good issues for the upcoming bluesky hackathon

Comments

@coretl
Copy link
Collaborator

coretl commented Apr 15, 2024

Need to document 2 ways:

  1. Exercise the device directly, i.e. call device.read() and inspect the output. Should use helpers made in Test helpers for assering value, reading and configuration #199
  2. Run a plan in the RunEngine and examine the docs. Use a pattern like:
from collections import defaultdict

def assert_emitted(docs: Dict[str, list], **numbers: int):
    assert list(docs) == list(numbers)
    assert {name: len(d) for name, d in docs.items()} == numbers

def test_plan():
    docs = defaultdict(list)
    RE(plan(), lambda name, doc: docs[name].append(doc))
    assert_emitted(docs, start=1, descriptor=1, resource=1, datum=1, event=1, stop=1)
@callumforrester
Copy link
Contributor

There is an existing docs page on testing that we can add to: https://blueskyproject.io/ophyd-async/main/user/how-to/write-tests-for-devices.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hackathon Good issues for the upcoming bluesky hackathon
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants