Skip to content

Commit c1d1ac5

Browse files
committed
add simple unit test for device_iterator
1 parent a2c51f4 commit c1d1ac5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

python/tests/sbp/client/test_logger.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
from sbp.client.loggers.base_logger import LogIterator
1414
from sbp.client.loggers.json_logger import JSONLogIterator, MultiJSONLogIterator
1515
from sbp.client.loggers.pickle_logger import PickleLogIterator
16+
from sbp.client.loggers.device_iterator import DeviceIterator
1617
from sbp.logging import SBP_MSG_PRINT
18+
from sbp.acquisition import SBP_MSG_ACQ_RESULT, MsgAcqResult
1719
from sbp.table import _SBP_TABLE, dispatch
1820
from sbp.table import InvalidSBPMessageType
21+
from sbp.client.handler import Handler
1922
import pytest
2023
import warnings
2124

@@ -151,3 +154,22 @@ def test_msg_print():
151154
assert len(w) == 1
152155
assert issubclass(w[0].category, RuntimeWarning)
153156
assert str(w[0].message).startswith('Bad message parsing for line')
157+
158+
def test_device_iterator():
159+
"""
160+
device iterator sanity tests.
161+
"""
162+
log_datafile = "data/one_msg.bin"
163+
handle = open(log_datafile, 'r')
164+
myhandler = Handler(handle.read, None, verbose=True)
165+
mydevice_iterator = DeviceIterator(myhandler, 0.5)
166+
myhandler.start()
167+
for delta, timestamp, msg in mydevice_iterator:
168+
assert delta > 0
169+
assert timestamp >0
170+
assert type(msg) == MsgAcqResult
171+
# warnings.simplefilter("always")
172+
# Check for warnings.
173+
#assert len(w) == 1
174+
#assert issubclass(w[0].category, RuntimeWarning)
175+
#assert str(w[0].message).startswith('Bad message parsing for line')

0 commit comments

Comments
 (0)