[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] Add doctest for bridgedb.schedule.ScheduledInterval.



commit e68aa51060775961f572bb800b3fd08f174852cb
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Tue Mar 31 10:29:07 2015 +0000

    Add doctest for bridgedb.schedule.ScheduledInterval.
---
 lib/bridgedb/schedule.py |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/bridgedb/schedule.py b/lib/bridgedb/schedule.py
index 4d0b8fd..659380f 100644
--- a/lib/bridgedb/schedule.py
+++ b/lib/bridgedb/schedule.py
@@ -138,6 +138,31 @@ class ScheduledInterval(Unscheduled):
     """An class that splits time into periods, based on seconds, minutes,
     hours, days, weeks, or months.
 
+    >>> from bridgedb.schedule import fromUnixSeconds
+    >>> from bridgedb.schedule import ScheduledInterval
+    >>> timestamp = 1427769526
+    >>> str(fromUnixSeconds(timestamp))
+    '2015-03-31 02:38:46'
+    >>> sched = ScheduledInterval(5, 'minutes')
+    >>> start = sched.intervalStart(timestamp)
+    >>> start
+    1427769300
+    >>> current = sched.getInterval(timestamp)
+    >>> current
+    '2015-03-31 02:35:00'
+    >>> current == str(fromUnixSeconds(start))
+    True
+    >>> next = sched.nextIntervalStarts(timestamp)
+    >>> next
+    1427769600
+    >>> str(fromUnixSeconds(next))
+    '2015-03-31 02:40:00'
+    >>> later = 1427771057
+    >>> str(fromUnixSeconds(later))
+    '2015-03-31 03:04:17'
+    >>> sched.getInterval(later)
+    '2015-03-31 03:00:00'
+
     :ivar str intervalPeriod: One of the :data:`KNOWN_INTERVALS`.
     :ivar int intervalCount: The number of times **intervalPeriod** should be
         repeated within an interval.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits