Use Beautiful Soup to check for favicon

This commit is contained in:
Sajith Sasidharan 2020-06-15 14:36:44 -04:00
parent 2e60408bf6
commit 1ee756c8df
2 changed files with 18 additions and 6 deletions

View File

@ -21,7 +21,12 @@ from allmydata.mutable import publish
from .. import common_util as testutil from .. import common_util as testutil
from ..common import WebErrorMixin, ShouldFailMixin from ..common import WebErrorMixin, ShouldFailMixin
from ..no_network import GridTestMixin from ..no_network import GridTestMixin
from .common import unknown_rwcap, unknown_rocap, unknown_immcap, FAVICON_MARKUP from .common import (
assert_soup_has_favicon,
unknown_immcap,
unknown_rocap,
unknown_rwcap,
)
DIR_HTML_TAG = '<html lang="en">' DIR_HTML_TAG = '<html lang="en">'
@ -92,7 +97,9 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
def _got_html_good(res): def _got_html_good(res):
self.failUnlessIn("Healthy", res) self.failUnlessIn("Healthy", res)
self.failIfIn("Not Healthy", res) self.failIfIn("Not Healthy", res)
self.failUnlessIn(FAVICON_MARKUP, res) soup = BeautifulSoup(res, 'html5lib')
assert_soup_has_favicon(self, soup)
d.addCallback(_got_html_good) d.addCallback(_got_html_good)
d.addCallback(self.CHECK, "good", "t=check&return_to=somewhere") d.addCallback(self.CHECK, "good", "t=check&return_to=somewhere")
def _got_html_good_return_to(res): def _got_html_good_return_to(res):
@ -235,7 +242,9 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
self.failUnlessIn("Healthy", res) self.failUnlessIn("Healthy", res)
self.failIfIn("Not Healthy", res) self.failIfIn("Not Healthy", res)
self.failUnlessIn("No repair necessary", res) self.failUnlessIn("No repair necessary", res)
self.failUnlessIn(FAVICON_MARKUP, res) soup = BeautifulSoup(res, 'html5lib')
assert_soup_has_favicon(self, soup)
d.addCallback(_got_html_good) d.addCallback(_got_html_good)
d.addCallback(self.CHECK, "sick", "t=check&repair=true") d.addCallback(self.CHECK, "sick", "t=check&repair=true")

View File

@ -3080,13 +3080,15 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
res = yield self.get_operation_results(None, "123", "html") res = yield self.get_operation_results(None, "123", "html")
self.failUnlessIn("Objects Checked: <span>11</span>", res) self.failUnlessIn("Objects Checked: <span>11</span>", res)
self.failUnlessIn("Objects Healthy: <span>11</span>", res) self.failUnlessIn("Objects Healthy: <span>11</span>", res)
self.failUnlessIn(FAVICON_MARKUP, res) soup = BeautifulSoup(res, 'html5lib')
assert_soup_has_favicon(self, soup)
res = yield self.GET("/operations/123/") res = yield self.GET("/operations/123/")
# should be the same as without the slash # should be the same as without the slash
self.failUnlessIn("Objects Checked: <span>11</span>", res) self.failUnlessIn("Objects Checked: <span>11</span>", res)
self.failUnlessIn("Objects Healthy: <span>11</span>", res) self.failUnlessIn("Objects Healthy: <span>11</span>", res)
self.failUnlessIn(FAVICON_MARKUP, res) soup = BeautifulSoup(res, 'html5lib')
assert_soup_has_favicon(self, soup)
yield self.shouldFail2(error.Error, "one", "404 Not Found", yield self.shouldFail2(error.Error, "one", "404 Not Found",
"No detailed results for SI bogus", "No detailed results for SI bogus",
@ -3136,7 +3138,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
self.failUnlessIn("Objects Unhealthy (after repair): <span>0</span>", res) self.failUnlessIn("Objects Unhealthy (after repair): <span>0</span>", res)
self.failUnlessIn("Corrupt Shares (after repair): <span>0</span>", res) self.failUnlessIn("Corrupt Shares (after repair): <span>0</span>", res)
self.failUnlessIn(FAVICON_MARKUP, res) soup = BeautifulSoup(res, 'html5lib')
assert_soup_has_favicon(self, soup)
d.addCallback(_check_html) d.addCallback(_check_html)
return d return d