From 46aae9eee008ef682ea8ee7335037bb7d0e4df2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Garc=C3=ADa=20Granda?= Date: Sun, 25 May 2014 19:29:10 +0200 Subject: [PATCH] Update record_test.py I guess scenarios where no heartrate data is present were missing in both testing and implementation. I propose new 3 test cases. --- pytrainer/test/record_test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pytrainer/test/record_test.py b/pytrainer/test/record_test.py index a0622f96..e580c91f 100644 --- a/pytrainer/test/record_test.py +++ b/pytrainer/test/record_test.py @@ -55,3 +55,26 @@ def test_hrFromLaps_handlingOfNone(self): ] self.assertEqual(self.record.hrFromLaps(laps), (160, 180)) + + def test_hrFromLaps_handlingOfBothAvgNone(self): + laps = [ + {'elapsed_time': 300, 'avg_hr': None, 'max_hr': 180}, + {'elapsed_time': 300, 'avg_hr': None, 'max_hr': 185} + ] + self.assertEqual(self.record.hrFromLaps(laps), (0, 185)) + + def test_hrFromLaps_handlingOfBothMaxNone(self): + laps = [ + {'elapsed_time': 300, 'avg_hr': 150, 'max_hr': None}, + {'elapsed_time': 300, 'avg_hr': 160, 'max_hr': None} + ] + self.assertEqual(self.record.hrFromLaps(laps), (155, 160)) + + + def test_hrFromLaps_handlingOfBothNone(self): + laps = [ + {'elapsed_time': 300, 'avg_hr': None, 'max_hr': None}, + {'elapsed_time': 300, 'avg_hr': None, 'max_hr': None} + ] + self.assertEqual(self.record.hrFromLaps(laps), (0, 0)) +