Skip to content

Commit da9a7a6

Browse files
committed
Add regression tests for named array registers
1 parent 0e34d21 commit da9a7a6

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

tests/data/device.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ registers:
1818
type: U8
1919
maskType: DigitalInputs
2020
description: Reports the state of the digital input lines.
21+
AnalogData:
22+
address: 44
23+
type: S16
24+
length: 3
25+
access: Event
26+
description: Reports the current values of the analog input lines.
2127
bitMasks:
2228
DigitalInputs:
2329
description: Specifies the state of the digital input lines.

tests/data/device_44.bin

18 Bytes
Binary file not shown.

tests/test_reader.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import numpy as np
1+
import pandas as pd
22
from pytest import mark
33

44
from harp.io import REFERENCE_EPOCH, MessageType
@@ -9,12 +9,12 @@
99
DeviceSchemaParam(
1010
path="data",
1111
expected_whoAmI=0,
12-
expected_registers=["DigitalInputMode"],
12+
expected_registers=["AnalogData"],
1313
),
1414
DeviceSchemaParam(
1515
path="data/device.yml",
1616
expected_whoAmI=0,
17-
expected_registers=["DigitalInputMode"],
17+
expected_registers=["AnalogData"],
1818
),
1919
]
2020

@@ -26,8 +26,13 @@ def test_create_reader(schemaFile: DeviceSchemaParam):
2626

2727
whoAmI = reader.WhoAmI.read()
2828
assert reader.device.whoAmI == whoAmI.iloc[0, 0]
29-
assert whoAmI.index.dtype.type == np.datetime64
29+
assert isinstance(whoAmI.index, pd.DatetimeIndex)
3030

3131
whoAmI = reader.WhoAmI.read(epoch=None, keep_type=True)
32-
assert whoAmI.index.dtype.type == np.float64
32+
assert isinstance(whoAmI.index, pd.Index)
3333
assert whoAmI.iloc[0, -1] == MessageType.READ.name
34+
35+
if schemaFile.expected_registers:
36+
for register_name in schemaFile.expected_registers:
37+
data = reader.registers[register_name].read()
38+
assert isinstance(data.index, pd.DatetimeIndex)

0 commit comments

Comments
 (0)