File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import os
2+
3+ from infuse_iot .tdf import TDF
4+
5+ # assert "TOXTEMPDIR" in os.environ, "you must run these tests using tox"
6+
7+ TESTDATA_FILENAME = os .path .join (os .path .dirname (__file__ ), "tdf_example.bin" )
8+
9+
10+ def test_tdf ():
11+ with open (TESTDATA_FILENAME , "rb" ) as f :
12+ test_data = f .read (- 1 )
13+
14+ test_blocks = [test_data [i : (i + 512 )] for i in range (0 , len (test_data ), 512 )]
15+
16+ decoder = TDF ()
17+ total_tdfs = 0
18+
19+ # Iterate over each block
20+ for block in test_blocks :
21+ assert len (block ) % 512 == 0
22+ # Iterate over each TDF in the block
23+ for tdf in decoder .decode (block ):
24+ assert isinstance (tdf , TDF .Reading )
25+ total_tdfs += 1
26+
27+ # Number of TDFs on the example block should never change
28+ assert total_tdfs == 53
You can’t perform that action at this time.
0 commit comments