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

[minion-cvs] stub surblog tests; support multiserver pings



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

Modified Files:
	ClientMain.py test.py 
Log Message:
stub surblog tests; support multiserver pings

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- ClientMain.py	29 May 2003 03:37:02 -0000	1.81
+++ ClientMain.py	29 May 2003 04:39:59 -0000	1.82
@@ -83,7 +83,7 @@
     # lastDownload: time when we last downloaded a directory
     # serverList: List of (ServerInfo, 'D'|'D-'|'I:filename') tuples.  The
     #   second element indicates whether the ServerInfo comes from a
-    #   directory or a file. DOCDOC D-
+    #   directory or a file.  ('D-' is an unrecommended server.)
     # fullServerList: List of (ServerInfo, 'D'|'D-'|'I:filename')
     #   tuples, including servers not on the Recommended-Servers list.
     # digestMap: Map of (Digest -> 'D'|'D-'|'I:filename').
@@ -95,7 +95,8 @@
     # __scanning: Flag to prevent recursive invocation of self.rescan().
     # clientVersions: String of allowable client versions as retrieved
     #    from most recent directory.
-    # goodServerNicknames: DOCDOC
+    # goodServerNicknames: A map from lowercased nicknames of recommended
+    #    servers to 1.
     ## Layout:
     # DIR/cache: A cPickled tuple of ("ClientKeystore-0.2",
     #         lastModified, lastDownload, clientVersions, serverlist,
@@ -304,7 +305,7 @@
                 self.__rebuildTables()
                 return
             else:
-                LOG.warn("Bad magic on directory cache; rebuilding...")
+                LOG.warn("Bad version on directory cache; rebuilding...")
         except (OSError, IOError):
             LOG.info("Couldn't read directory cache; rebuilding")
         except (cPickle.UnpicklingError, ValueError), e:
@@ -987,7 +988,7 @@
         s = f.read()
         f.close()
         if not s.startswith(magic):
-            raise MixError("Invalid magic on key file")
+            raise MixError("Invalid versioning on key file")
 
     def _save(self, fn, data, magic, password):
         """Save the key data 'data' into the file 'fn' using the magic string
@@ -1109,8 +1110,6 @@
     """A SURBLog manipulates a database on disk to remember which SURBs we've
        used, so we don't reuse them accidentally.
        """
-    # XXXX004 write unit tests
-
     #FFFF Using this feature should be optional.
 
     ##Fields
@@ -2215,8 +2214,8 @@
     options, args = getopt.getopt(args, "hvf:D:",
              ["help", "verbose", "config=", "download-directory=", ])
 
-    if len(args) != 1:
-        raise UsageError("mixminion ping requires a single server name")
+    if len(args) == 0:
+        raise UsageError("(No servers provided)")
 
 
     print "==========================================================="
@@ -2236,13 +2235,14 @@
     directory = parser.directory
     client = parser.client
 
-    info = directory.getServerInfo(args[0],
-                                   startAt=time.time(), endAt = time.time(),
-                                   strict=1)
+    for arg in args:
+        info = directory.getServerInfo(arg,
+                                       startAt=time.time(), endAt=time.time(),
+                                       strict=1)
 
-    ok, status = client.pingServer(info.getRoutingInfo())
-    print ">>>", status
-    print info.getNickname(), (ok and "is up" or "is down")
+        ok, status = client.pingServer(info.getRoutingInfo())
+        print ">>>", status
+        print info.getNickname(), (ok and "is up" or "is down")
 
 _IMPORT_SERVER_USAGE = """\
 Usage: %(cmd)s [options] <filename> ...

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- test.py	29 May 2003 01:56:08 -0000	1.111
+++ test.py	29 May 2003 04:39:59 -0000	1.112
@@ -5555,6 +5555,17 @@
         parseFails("0x9999") # No data
         parseFails("0xFEEEF:zymurgy") # Hex literal out of range
 
+    def testSURBLog(self):
+        SURBLog = mixminion.ClientMain.SURBLog
+        dirname = mix_mktemp()
+        fname = os.path.join(dirname, "surblog")
+        s = SURBLog(fname)
+        try:
+            #XXXX writeme
+            pass
+        finally:
+            s.close()
+
     def testClientKeyring(self):
         keydir = mix_mktemp()
         keyring = mixminion.ClientMain.ClientKeyring(keydir)
@@ -5736,7 +5747,7 @@
     tc = loader.loadTestsFromTestCase
 
     if 0:
-        suite.addTest(tc(QueueTests))
+        suite.addTest(tc(ClientMainTests))
         return suite
 
     suite.addTest(tc(MiscTests))