Unverified Commit 91142d6c authored by Isis Lovecruft's avatar Isis Lovecruft
Browse files

Merge branch 'rransom/fix/12147-schedule-unittest' into develop

parents 024c978f a7551e22
......@@ -91,6 +91,10 @@ class Unscheduled(object):
def getInterval(self, when=0):
"""Get the interval that contains the time **when**.
.. note: We explicitly ignore the ``when`` parameter in this
implementation because if something is Unscheduled then
all timestamps should reside within the same period.
:param int when: The time which we're trying to find the corresponding
interval for.
:rtype: str
......@@ -98,8 +102,9 @@ class Unscheduled(object):
specificity depends on what type of interval we're using. For
example, if using ``"month"``, the return value would be something
like ``"2013-12"``.
"""
return fromUnixSeconds(when).strftime('%04Y-%02m-%02d %02H:%02M:%02S')
return fromUnixSeconds(0).strftime('%04Y-%02m-%02d %02H:%02M:%02S')
def nextIntervalStarts(self, when=0):
"""Return the start time of the interval starting _after_ when.
......
......@@ -36,10 +36,21 @@ class UnscheduledTests(unittest.TestCase):
self.assertIsInstance(time, int)
self.assertEquals(time, -62135596800)
def test_Unscheduled_getInterval_noargs(self):
time = self.sched.getInterval()
self.assertIsInstance(time, str)
self.assertEquals(time, "1970-01-01 00:00:00")
def test_Unscheduled_getInterval_is_constant(self):
import time
now = time.time()
interval_default = self.sched.getInterval()
self.assertIsInstance(interval_default, str)
interval_zero = self.sched.getInterval(0)
self.assertIsInstance(interval_zero, str)
interval_now = self.sched.getInterval(now)
self.assertIsInstance(interval_now, str)
self.assertEquals(interval_default, interval_zero)
self.assertEquals(interval_default, interval_now)
def test_Unscheduled_nextIntervalStarts_noargs(self):
time = self.sched.nextIntervalStarts()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment