forked from bluesky/resource-health-check
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
30 lines (24 loc) · 1020 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import subprocess
import pytest
from ophyd.sim import NumpySeqHandler, img
from bluesky import RunEngine
from bluesky.plans import count
from event_model import RunRouter, UndefinedAssetSpecification
from resource_health_check import handler_registry, validator_factory_raising
def test_basic_functionality():
"A simple test demonstrating validation failure and success"
handler_registry.clear()
RE = RunEngine()
rr = RunRouter([validator_factory_raising])
RE.subscribe(rr)
# This should fail because there is no handler registered.
with pytest.raises(UndefinedAssetSpecification):
RE(count([img]))
# Register the handler...
handler_registry.update({'NPY_SEQ': NumpySeqHandler})
# ...and now the validator should be satisfied.
RE(count([img]))
def test_cli_help():
"Test that the CLI starts up without errors."
# This raises CalledProcessError if it exits with a nonzero exit code.
subprocess.check_call(['python', 'resource_health_check.py', '-h'])