Simplify WebResultsRendering.test_literal

This commit is contained in:
Sajith Sasidharan 2020-06-11 15:48:44 -04:00
parent 77120ba70c
commit 02cd42c130

View File

@ -79,29 +79,23 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
def test_literal(self): def test_literal(self):
lcr = web_check_results.LiteralCheckResultsElement() lcr = web_check_results.LiteralCheckResultsElement()
d = self.render_element(lcr) html = self.render_element(lcr)
def _check(html):
s = self.remove_tags(html) s = self.remove_tags(html)
self.failUnlessIn("Literal files are always healthy", s) self.failUnlessIn("Literal files are always healthy", s)
_check(d)
d = self.render_element(lcr, args={"return_to": ["FOOURL"]}) html = self.render_element(lcr, args={"return_to": ["FOOURL"]})
def _check_return_to(html):
s = self.remove_tags(html) s = self.remove_tags(html)
self.failUnlessIn("Literal files are always healthy", s) self.failUnlessIn("Literal files are always healthy", s)
self.failUnlessIn('<a href="FOOURL">Return to file.</a>', self.failUnlessIn('<a href="FOOURL">Return to file.</a>', html)
html)
_check_return_to(d)
c = self.create_fake_client() c = self.create_fake_client()
lcr = web_check_results.LiteralCheckResultsRenderer(c) lcr = web_check_results.LiteralCheckResultsRenderer(c)
d = self.render_json(lcr) js = self.render_json(lcr)
def _check_json(js):
j = json.loads(js) j = json.loads(js)
self.failUnlessEqual(j["storage-index"], "") self.failUnlessEqual(j["storage-index"], "")
self.failUnlessEqual(j["results"]["healthy"], True) self.failUnlessEqual(j["results"]["healthy"], True)
_check_json(d)
def test_check(self): def test_check(self):
c = self.create_fake_client() c = self.create_fake_client()