コード例 #1
0
 def testPoll(self):
     """Test polling the timer."""
     interval_hours = 0.0001
     t = diagnosis_utils.SimpleTimer(interval_hours=interval_hours)
     deadline = t.deadline
     self.assertTrue(deadline is not None and
                     t.interval_hours == interval_hours)
     min_deadline = (datetime.now() +
                     datetime_base.timedelta(hours=interval_hours))
     time.sleep(interval_hours * 3600)
     self.assertTrue(t.poll())
     self.assertTrue(t.deadline >= min_deadline)
コード例 #2
0
 def testBadInterval(self):
     """Test a bad interval."""
     t = diagnosis_utils.SimpleTimer(interval_hours=-1)
     self.assertTrue(t.deadline is None and t.poll() == False)
     t._reset()
     self.assertTrue(t.deadline is None and t.poll() == False)