Exemple #1
0
 def test_prettify_seconds(self):
     eq_(util.prettify_seconds(1), '1 second')
     eq_(util.prettify_seconds(2), '2 seconds')
     eq_(util.prettify_seconds(60), '1 minute')
     eq_(util.prettify_seconds(62), '1 minute and 2 seconds')
     eq_(util.prettify_seconds(60*60), '1 hour')
     eq_(util.prettify_seconds(3600 + 2), '1 hour and 2 seconds')
     eq_(util.prettify_seconds(60*60+62), '1 hour, 1 minute and 2 seconds')
     eq_(util.prettify_seconds(86400), '1 day')
Exemple #2
0
 def fair_use_delay(self):
     "Delay server query according to Request Frequency policy"
     delay = self.get_fair_use_delay()
     if delay < 0:
         log.error("got negative delay: '%s', will not sleep", delay)
     elif not self.discard_fair_use_policy:
         log.info('Sleeping for %s', util.prettify_seconds(delay))
         time.sleep(delay)
     else:
         log.debug("didn't sleep because of settings")
Exemple #3
0
 def test_prettify_seconds_error(self):
     util.prettify_seconds(-5)