From 8fd0cf7eb6de6b57ad0e659f7694d89c1fa93ed3 Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan <sajith@nonzen.in> Date: Fri, 17 Jul 2020 11:40:18 -0400 Subject: [PATCH] Add a test for checking status page links --- src/allmydata/test/web/test_web.py | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/allmydata/test/web/test_web.py b/src/allmydata/test/web/test_web.py index 1c155f6ce..d787124eb 100644 --- a/src/allmydata/test/web/test_web.py +++ b/src/allmydata/test/web/test_web.py @@ -1047,6 +1047,58 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi self.GET, "/status/nodash") + def test_status_page_contains_links(self): + """ + Check that the rendered `/status` page contains all the + expected links. + """ + def _check_status_page_links(response): + (body, status, _) = response + + self.failUnlessReallyEqual(int(status), 200) + + soup = BeautifulSoup(body, 'html5lib') + + # Check for `<a href="/status/retrieve-0">Not started</a>` + assert_soup_has_tag_with_attributes_and_content( + self, soup, u"a", + u"Not started", + {u"href": u"/status/retrieve-0"} + ) + + # Check for `<a href="/status/publish-0">Not started</a></td>` + assert_soup_has_tag_with_attributes_and_content( + self, soup, u"a", + u"Not started", + {u"href": u"/status/publish-0"} + ) + + # Check for `<a href="/status/mapupdate-0">Not started</a>` + assert_soup_has_tag_with_attributes_and_content( + self, soup, u"a", + u"Not started", + {u"href": u"/status/mapupdate-0"} + ) + + # Check for `<a href="/status/down-0">fetching segments + # 2,3; errors on segment 1</a>`: see build_one_ds() above. + assert_soup_has_tag_with_attributes_and_content( + self, soup, u"a", + u"fetching segments 2,3; errors on segment 1", + {u"href": u"/status/down-0"} + ) + + # Check for `<a href="/status/up-0">Not started</a>` + assert_soup_has_tag_with_attributes_and_content( + self, soup, u"a", + u"Not started", + {u"href": u"/status/up-0"} + ) + + d = self.GET("/status", return_response=True) + d.addCallback(_check_status_page_links) + return d + def test_status_path_trailing_slashes(self): """ Test that both `GET /status` and `GET /status/` are treated