Document, use, and test "join pathstring" method

This commit is contained in:
Sajith Sasidharan 2020-07-15 16:38:30 -04:00
parent 589e143a4a
commit 6969366370
2 changed files with 15 additions and 3 deletions

View File

@ -118,7 +118,7 @@ class FakeDeepCheckResults(object):
return { return {
# TODO: fill this, perhaps with one each of healthy, # TODO: fill this, perhaps with one each of healthy,
# unhealthy, unrecoverable, corrupt. # unhealthy, unrecoverable, corrupt.
"fake-result-path": FakeResults() (u"some", u"fake", u"path"): FakeResults()
} }
def get_corrupt_shares(self): def get_corrupt_shares(self):
@ -473,6 +473,11 @@ class WebResultsRendering(unittest.TestCase):
u"Files/Directories That Had Problems:" u"Files/Directories That Had Problems:"
) )
assert_soup_has_tag_with_content(
self, soup, u"li",
u"some/fake/path: fake summary results [SI: mzqwwzjnonuq]"
)
assert_soup_has_tag_with_content( assert_soup_has_tag_with_content(
self, soup, u"h2", self, soup, u"h2",
u"Servers on which corrupt shares were found" u"Servers on which corrupt shares were found"

View File

@ -91,6 +91,13 @@ class ResultsBase(object):
# determine the permuted peer order # determine the permuted peer order
def _join_pathstring(self, path): def _join_pathstring(self, path):
"""
:param tuple path: a path represented by a tuple, such as
``(u'some', u'dir', u'file')``.
:return: a string joined by path separaters, such as
``u'some/dir/file'``.
"""
if path: if path:
pathstring = "/".join(self._html(path)) pathstring = "/".join(self._html(path))
else: else:
@ -504,7 +511,7 @@ class DeepCheckResultsRendererElement(Element, ResultsBase, ReloadMixin):
problems.append({ problems.append({
# Not sure self._join_pathstring(path) is the # Not sure self._join_pathstring(path) is the
# right thing to use here. # right thing to use here.
"problem": self._html(path) + self._html(summary_text), "problem": self._join_pathstring(path) + self._html(summary_text),
}) })
return SlotsSequenceElement(tag, problems) return SlotsSequenceElement(tag, problems)
@ -573,7 +580,7 @@ class DeepCheckResultsRendererElement(Element, ResultsBase, ReloadMixin):
result = results.get(path) result = results.get(path)
storage_index = result.get_storage_index() storage_index = result.get_storage_index()
object = { object = {
"path": self._html(path), "path": self._join_pathstring(path),
"healthy": str(result.is_healthy()), "healthy": str(result.is_healthy()),
"recoverable": str(result.is_recoverable()), "recoverable": str(result.is_recoverable()),
"storage_index": self._render_si_link(req, storage_index), "storage_index": self._render_si_link(req, storage_index),