[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Tests and docs for succeedingMidnight



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv1715/lib/mixminion

Modified Files:
	Common.py test.py 
Log Message:
Tests and docs for succeedingMidnight

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- Common.py	9 Feb 2003 22:30:58 -0000	1.57
+++ Common.py	12 Feb 2003 01:21:46 -0000	1.58
@@ -11,7 +11,7 @@
             'formatFnameTime', 'formatTime', 'installSIGCHLDHandler',
             'isSMTPMailbox', 'openUnique', 'previousMidnight',
             'readPossiblyGzippedFile', 'secureDelete', 'stringContains',
-            'waitForChildren' ]
+            'succeedingMidnight', 'waitForChildren' ]
 
 import base64
 import bisect
@@ -573,8 +573,8 @@
     return calendar.timegm((yyyy,MM,dd,0,0,0,0,0,0))
 
 def succeedingMidnight(when):
-    "DOCDOC"
-    #XXXX003 test me
+    """Given a time_t 'when', return the smallest time_t > when that falls
+       on midnight, GMT."""
     yyyy,MM,dd = time.gmtime(when)[0:3]
     return calendar.timegm((yyyy,MM,dd+1,0,0,0,0,0,0))
 
@@ -863,6 +863,7 @@
 #----------------------------------------------------------------------
 class Lockfile:
     "DOCDOC"
+    #XXXX Testme.
     def __init__(self, filename):
         "DOCDOC"
         self.filename = filename

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- test.py	11 Feb 2003 22:18:16 -0000	1.83
+++ test.py	12 Feb 2003 01:21:46 -0000	1.84
@@ -205,6 +205,25 @@
             # 3. That previousMidnight is idempotent
             self.assertEquals(previousMidnight(pm), pm)
 
+            # 4. That succeedingMidnight returns the next day, at midnight.
+            sm = succeedingMidnight(t)
+            yyyy2,MM2,dd2,hh2,mm2,ss2 = time.gmtime(sm)[:6]
+            self.assertEquals((0,0,0), (hh2, mm2, ss2))
+            if dd2 == dd + 1:
+                self.assertEquals((yyyy2, MM2), (yyyy, MM))
+            elif MM2 == MM + 1:
+                self.assertEquals((yyyy2, dd2), (yyyy, 1))
+            else:
+                self.assertEquals((yyyy2, MM2, dd2), (yyyy+1, 1, 1))
+            # 5. That succeedingMidnight is repeatable
+            self.assertEquals(succeedingMidnight(t), sm)
+            # 6. That sm(pm(x)) = sm(x)
+            self.assertEquals(succeedingMidnight(previousMidnight(t)),
+                              succeedingMidnight(t))
+            # 7. That pm(sm(x)) = sm(x)
+            self.assertEquals(previousMidnight(succeedingMidnight(t)),
+                              succeedingMidnight(t))
+
         now = time.time()
         ft = formatFnameTime(now)
         tm = time.localtime(now)
@@ -4024,7 +4043,7 @@
 """
 
 class FakeDeliveryPacket(mixminion.server.PacketHandler.DeliveryPacket):
-    "DOCDOC"
+    """Stub version of DeliveryPacket used for testing modules"""
     def __init__(self, type, exitType, exitAddress, contents, tag=None):
         if tag is None:
             tag = "-="*10