commit 9edb69565eb7968c101452662a18dd778b13193d Author: Isis Lovecruft isis@torproject.org Date: Tue Mar 31 10:29:57 2015 +0000
Add test for b.s.ScheduledInterval.intervalStart() that exposes a bug.
ScheduledInterval.intervalStart(), when called with a float, i.e. as is returned from time.time() which is used by the email distributor to pass timestamps into ScheduledInterval.intervalStart(), returns a float. This could cause bugs in other parts of the code which expect ints for timestamps. --- lib/bridgedb/test/test_schedule.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/lib/bridgedb/test/test_schedule.py b/lib/bridgedb/test/test_schedule.py index f5ab886..6a38871 100644 --- a/lib/bridgedb/test/test_schedule.py +++ b/lib/bridgedb/test/test_schedule.py @@ -143,6 +143,18 @@ class ScheduledIntervalTests(unittest.TestCase): def test_ScheduledInterval_intervalStart_seconds(self): self._check_intervalStart(30, 'seconds', 30)
+ def test_ScheduledInterval_intervalStart_time_time(self): + """Calling ScheduledInterval.intervalStart(time.time()) should only + return ints, not floats. + """ + import time + + timestamp = time.time() + sched = self.sched(5, 'minutes') + + self.assertIsInstance(timestamp, float) + self.assertIsInstance(sched.intervalStart(timestamp), int) + def _check_getInterval(self, count=30, period='second', variance=30): """Test the ScheduledInterval.getInterval() method.