MCPcopy Create free account
hub / github.com/coleifer/huey / test_zero_delay

Method test_zero_delay

huey/tests/test_utils.py:80–95  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

78 self.assertEqual(normalize_time(ts, utc=True), ts_local)
79
80 def test_zero_delay(self):
81 # A delay of zero means "now" -- it is not treated as missing.
82 for utc in (False, True):
83 ref = utcnow() if utc else datetime.datetime.now()
84 for delay in (0, datetime.timedelta(seconds=0)):
85 eta = normalize_time(delay=delay, utc=utc)
86 self.assertTrue(eta is not None)
87 self.assertTrue(abs((eta - ref).total_seconds()) < 5)
88
89 # Same for expiration: expires=0 means "expires immediately",
90 # not "never expires".
91 expires = normalize_expire_time(0, utc=utc)
92 self.assertTrue(abs((expires - ref).total_seconds()) < 5)
93
94 # Omitting both eta and delay is still an error.
95 self.assertRaises(ValueError, normalize_time)
96
97
98class TestFileLock(unittest.TestCase):

Callers

nothing calls this directly

Calls 3

utcnowFunction · 0.90
normalize_timeFunction · 0.90
normalize_expire_timeFunction · 0.90

Tested by

no test coverage detected