From: Brian Warner Date: Fri, 25 May 2012 07:13:13 +0000 (-0700) Subject: CheckResults: simplify self._data X-Git-Url: https://git.rkrishnan.org/frontends/specifications/install.html?a=commitdiff_plain;h=d44689728243d6716a9a678bbf5792ab3a213482;p=tahoe-lafs%2Ftahoe-lafs.git CheckResults: simplify self._data --- diff --git a/src/allmydata/check_results.py b/src/allmydata/check_results.py index 7224a6f8..445eed73 100644 --- a/src/allmydata/check_results.py +++ b/src/allmydata/check_results.py @@ -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 diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 77b1d08c..ff9db980 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -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]} diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index dc7d90fd..816c57fd 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -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]},