]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
#514: improve test coverage
authorBrian Warner <warner@lothar.com>
Wed, 22 Oct 2008 00:52:56 +0000 (17:52 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 22 Oct 2008 00:52:56 +0000 (17:52 -0700)
src/allmydata/monitor.py
src/allmydata/test/test_web.py
src/allmydata/web/directory.py

index dad89b853fc737789429450a9dd24349a43a08cc..22de77132d1afb7496a53b22cb24152f52c2ad11 100644 (file)
@@ -100,21 +100,3 @@ class Monitor:
         return self.status
     def set_status(self, status):
         self.status = status
-
-class MonitorTable:
-    def __init__(self):
-        self.handles = {} # maps ophandle (an arbitrary string) to a Monitor
-        # TODO: all timeouts, handle lifetime, retain-for=, etc, goes here.
-        # self.handles should probably be a WeakValueDictionary, and we need
-        # a table of timers, and operations which have finished should be
-        # handled slightly differently.
-
-    def get_monitor(self, handle):
-        return self.handles.get(handle)
-
-    def add_monitor(self, handle, monitor):
-        self.handles[handle] = monitor
-
-    def delete_monitor(self, handle):
-        if handle in self.handles:
-            del self.handles[handle]
index 695d9bfc861e2a48633709d639dc94124ade827b..2b0c16fd1cd566833dd0f278da8a1a88f9c089b9 100644 (file)
@@ -2150,6 +2150,21 @@ class Web(WebMixin, testutil.StallMixin, unittest.TestCase):
                                   client.getPage, url, method="DELETE")
         return d
 
+    def test_bad_ophandle(self):
+        url = self.webish_url + "/operations/bogus?t=status"
+        d = self.shouldHTTPError2("test_bad_ophandle", 400, "400 Bad Request",
+                                  "unknown/expired handle 'bogus'",
+                                  client.getPage, url)
+        return d
+
+    def test_incident(self):
+        d = self.POST("/report_incident", details="eek")
+        def _done(res):
+            self.failUnless("Thank you for your report!" in res, res)
+        d.addCallback(_done)
+        return d
+
+
 class Util(unittest.TestCase):
     def test_abbreviate_time(self):
         self.failUnlessEqual(common.abbreviate_time(None), "")
index a1f33d30bac51961d666ceadbddb26e4410103f4..79dcef394e04176cd83a3accb408740251abea16 100644 (file)
@@ -721,10 +721,8 @@ class ManifestResults(rend.Page, ReloadMixin):
     def text(self, ctx):
         inevow.IRequest(ctx).setHeader("content-type", "text/plain")
         lines = []
-        if self.monitor.is_finished():
-            lines.append("finished: yes")
-        else:
-            lines.append("finished: no")
+        is_finished = self.monitor.is_finished()
+        lines.append("finished: " + {True: "yes", False: "no"}[is_finished])
         for (path, cap) in self.monitor.get_status():
             lines.append(self.slashify_path(path) + " " + cap)
         return "\n".join(lines) + "\n"
@@ -773,15 +771,14 @@ class DeepSizeResults(rend.Page):
         if output == "json":
             return self.json(ctx)
         # plain text
-        if self.monitor.is_finished():
-            output = "finished: true\n"
+        is_finished = self.monitor.is_finished()
+        output = "finished: " + {True: "yes", False: "no"}[is_finished] + "\n"
+        if is_finished:
             stats = self.monitor.get_status()
             total = (stats.get("size-immutable-files", 0)
                      + stats.get("size-mutable-files", 0)
                      + stats.get("size-directories", 0))
             output += "size: %d\n" % total
-        else:
-            output = "finished: false\n"
         return output
 
     def json(self, ctx):