-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_triggered_sensor.py
More file actions
53 lines (42 loc) · 1.24 KB
/
test_triggered_sensor.py
File metadata and controls
53 lines (42 loc) · 1.24 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pathlib
import subprocess
import sys
import time
import math
import pytest
import yaqc
import yaqd_core
from yaqd_core import testing
config = pathlib.Path(__file__).parent / "config.toml"
@testing.run_daemon_entry_point("fake-triggered-sensor", config=config)
def test_measurement_id():
c = yaqc.Client(39426)
assert c.get_measurement_id() == 0
target = c.measure()
assert target == 1
while c.busy():
time.sleep(0.1)
a = c.get_measurement_id()
b = c.get_measured()["measurement_id"]
assert isinstance(target, int)
assert isinstance(a, int)
assert isinstance(b, int)
assert a == b == target
@testing.run_daemon_entry_point("fake-triggered-sensor", config=config)
def test_defaults():
c = yaqc.Client(39426)
c.measure()
while c.busy():
time.sleep(0.1)
out = c.get_measured()["random_walk"]
assert -1 <= out <= 1
@testing.run_daemon_entry_point("fake-triggered-sensor", config=config)
def test_shapes():
# get_channel_shapes returns a tuple
# this test ensures that fastavro doesn't break
c = yaqc.Client(39426)
for k, v in c.get_channel_shapes().items():
assert hasattr(v, "__iter__")
if __name__ == "__main__":
test_defaults()
test_shapes()