CheckResults: simplify self._data
authorBrian Warner <warner@lothar.com>
Fri, 25 May 2012 07:13:13 +0000 (00:13 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 2 Jun 2012 18:39:09 +0000 (11:39 -0700)
src/allmydata/check_results.py
src/allmydata/test/common.py
src/allmydata/test/test_checker.py

index 7224a6f80c2bf702b4935866ab2009ca2fac50fd..445eed739532755f378cb30313e8d2f0c0df8259 100644 (file)
@@ -12,9 +12,6 @@ class CheckResults:
         self.uri = uri
         self.storage_index = storage_index
         self.problems = []
-        self._data = {"count-corrupt-shares": 0,
-                      "list-corrupt-shares": [],
-                      }
         self.summary = ""
         self.report = []
 
@@ -34,7 +31,7 @@ class CheckResults:
     def set_needs_rebalancing(self, needs_rebalancing):
         self.needs_rebalancing_p = bool(needs_rebalancing)
     def set_data(self, data):
-        self._data.update(data)
+        self._data = data
     def set_summary(self, summary):
         assert isinstance(summary, str) # should be a single string
         self.summary = summary
index 77b1d08ce5ea180db8100d688afdc6c463a3ab99..ff9db980a6f57c2189304ba9f8903b682e5be3a7 100644 (file)
@@ -73,6 +73,7 @@ class FakeCHKFileNode:
         data["count-good-share-hosts"] = 10
         data["count-wrong-shares"] = 0
         nodeid = "\x00"*20
+        data["count-corrupt-shares"] = 0
         data["list-corrupt-shares"] = []
         data["sharemap"] = {1: [nodeid]}
         data["servers-responding"] = [nodeid]
@@ -281,6 +282,7 @@ class FakeMutableFileNode:
         data["count-shares-expected"] = 10
         data["count-good-share-hosts"] = 10
         data["count-wrong-shares"] = 0
+        data["count-corrupt-shares"] = 0
         data["list-corrupt-shares"] = []
         nodeid = "\x00"*20
         data["sharemap"] = {"seq1-abcd-sh0": [nodeid]}
index dc7d90fddb787e16531528626698d03486ff9445..816c57fd8d8095e3cf2cd6aa14a3866338d82611 100644 (file)
@@ -89,6 +89,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
                  "count-shares-expected": 9,
                  "count-shares-good": 10,
                  "count-good-share-hosts": 11,
+                 "count-corrupt-shares": 0,
                  "list-corrupt-shares": [],
                  "count-wrong-shares": 0,
                  "sharemap": {"shareid1": [serverid_1, serverid_f]},
@@ -121,6 +122,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
         cr.set_healthy(False)
         cr.set_recoverable(False)
         cr.set_summary("rather dead")
+        data["count-corrupt-shares"] = 1
         data["list-corrupt-shares"] = [(serverid_1, u.get_storage_index(), 2)]
         cr.set_data(data)
         html = self.render2(w)
@@ -159,7 +161,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
                         'count-good-share-hosts': 11,
                         'count-wrong-shares': 0,
                         'count-shares-good': 10,
-                        'count-corrupt-shares': 0,
+                        'count-corrupt-shares': 1,
                         'servers-responding': [],
                         'recoverable': False,
                         }
@@ -189,6 +191,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
                  "count-shares-expected": 10,
                  "count-shares-good": 6,
                  "count-good-share-hosts": 7,
+                 "count-corrupt-shares": 0,
                  "list-corrupt-shares": [],
                  "count-wrong-shares": 0,
                  "sharemap": {"shareid1": [serverid_1, serverid_f]},
@@ -207,6 +210,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
                  "count-shares-expected": 10,
                  "count-shares-good": 10,
                  "count-good-share-hosts": 11,
+                 "count-corrupt-shares": 0,
                  "list-corrupt-shares": [],
                  "count-wrong-shares": 0,
                  "sharemap": {"shareid1": [serverid_1, serverid_f]},