From f04ae471b8229c0dd9c69ca7c059771cd3549df8 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 1 Jan 2020 22:55:47 -0800 Subject: [PATCH] add some comments to the tests.. --- RainEagle/parse.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RainEagle/parse.py b/RainEagle/parse.py index 0b42561..975afb0 100644 --- a/RainEagle/parse.py +++ b/RainEagle/parse.py @@ -249,6 +249,8 @@ m 1572793208.3 1572764405 Connected 0 0 kW 0 0 kWh s = StringIO(self.zonelines) pos = 10 s.seek(pos) + + # generate an index genidx = ParseLog.generateIndex(s, 2) 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 self.assertEqual(s.tell(), pos) + # make sure the index has the correct information self.assertEqual(genidx['length'], len(s.getvalue())) self.assertEqual(genidx['index'], [ (1572767995, zpos[0]), (1572778900, zpos[1]) ]) + # and that verify index works self.assertTrue(ParseLog.verifyIndex(genidx, s)) s.seek(pos) tmp = genidx.copy() tmp['length'] = 0 + + # that is fails when the length is wrong self.assertFalse(ParseLog.verifyIndex(tmp, s)) tmp = genidx.copy() tmp['index'][0] = (tmp['index'][0][0], 10) + + # that it fails when the position is wrong self.assertFalse(ParseLog.verifyIndex(tmp, s)) # that the position remained the same