Browse Source

add some comments to the tests..

main
John-Mark Gurney 5 years ago
parent
commit
f04ae471b8
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      RainEagle/parse.py

+ 8
- 0
RainEagle/parse.py View File

@@ -249,6 +249,8 @@ m 1572793208.3 1572764405 Connected 0 0 kW 0 0 kWh
s = StringIO(self.zonelines) s = StringIO(self.zonelines)
pos = 10 pos = 10
s.seek(pos) s.seek(pos)

# generate an index
genidx = ParseLog.generateIndex(s, 2) genidx = ParseLog.generateIndex(s, 2)


zpos = [ i for i, x in enumerate(self.zonelines) if x == 'z' ] zpos = [ i for i, x in enumerate(self.zonelines) if x == 'z' ]
@@ -256,19 +258,25 @@ m 1572793208.3 1572764405 Connected 0 0 kW 0 0 kWh
# that the position remained the same # that the position remained the same
self.assertEqual(s.tell(), pos) self.assertEqual(s.tell(), pos)


# make sure the index has the correct information
self.assertEqual(genidx['length'], len(s.getvalue())) self.assertEqual(genidx['length'], len(s.getvalue()))
self.assertEqual(genidx['index'], [ (1572767995, zpos[0]), (1572778900, zpos[1]) ]) self.assertEqual(genidx['index'], [ (1572767995, zpos[0]), (1572778900, zpos[1]) ])


# and that verify index works
self.assertTrue(ParseLog.verifyIndex(genidx, s)) self.assertTrue(ParseLog.verifyIndex(genidx, s))


s.seek(pos) s.seek(pos)


tmp = genidx.copy() tmp = genidx.copy()
tmp['length'] = 0 tmp['length'] = 0

# that is fails when the length is wrong
self.assertFalse(ParseLog.verifyIndex(tmp, s)) self.assertFalse(ParseLog.verifyIndex(tmp, s))


tmp = genidx.copy() tmp = genidx.copy()
tmp['index'][0] = (tmp['index'][0][0], 10) tmp['index'][0] = (tmp['index'][0][0], 10)

# that it fails when the position is wrong
self.assertFalse(ParseLog.verifyIndex(tmp, s)) self.assertFalse(ParseLog.verifyIndex(tmp, s))


# that the position remained the same # that the position remained the same


Loading…
Cancel
Save