mirror of https://github.com/zulip/zulip.git
doc tests: Introoduce _is_landing_page helper.
This makes us correctly run landing page logic where we didn't before, and, more importantly, lets us skip landing page logic where we had been erroneously running it. This speeds up my runs from 35s to 25s.
This commit is contained in:
parent
407c16fc77
commit
018634bbfd
|
@ -38,6 +38,20 @@ class DocPageTest(ZulipTestCase):
|
||||||
print("ERROR: {}".format(content.get("msg")))
|
print("ERROR: {}".format(content.get("msg")))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
def _is_landing_page(self, url: str) -> bool:
|
||||||
|
for prefix in [
|
||||||
|
"/api/",
|
||||||
|
"/devlogin/",
|
||||||
|
"/devtools/",
|
||||||
|
"/emails/",
|
||||||
|
"/errors/",
|
||||||
|
"/help/",
|
||||||
|
"/integrations/",
|
||||||
|
]:
|
||||||
|
if url.startswith(prefix):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def _test_normal_path(
|
def _test_normal_path(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
@ -45,7 +59,6 @@ class DocPageTest(ZulipTestCase):
|
||||||
expected_content: str,
|
expected_content: str,
|
||||||
extra_strings: Sequence[str],
|
extra_strings: Sequence[str],
|
||||||
landing_missing_strings: Sequence[str],
|
landing_missing_strings: Sequence[str],
|
||||||
landing_page: bool,
|
|
||||||
doc_html_str: bool,
|
doc_html_str: bool,
|
||||||
search_disabled: bool,
|
search_disabled: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -63,7 +76,7 @@ class DocPageTest(ZulipTestCase):
|
||||||
for s in extra_strings:
|
for s in extra_strings:
|
||||||
self.assertIn(s, str(result.content))
|
self.assertIn(s, str(result.content))
|
||||||
|
|
||||||
if not landing_page:
|
if not self._is_landing_page(url):
|
||||||
return
|
return
|
||||||
|
|
||||||
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
||||||
|
@ -104,7 +117,6 @@ class DocPageTest(ZulipTestCase):
|
||||||
expected_content: str,
|
expected_content: str,
|
||||||
extra_strings: Sequence[str],
|
extra_strings: Sequence[str],
|
||||||
landing_missing_strings: Sequence[str],
|
landing_missing_strings: Sequence[str],
|
||||||
landing_page: bool,
|
|
||||||
doc_html_str: bool,
|
doc_html_str: bool,
|
||||||
search_disabled: bool,
|
search_disabled: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -121,7 +133,7 @@ class DocPageTest(ZulipTestCase):
|
||||||
['<meta name="robots" content="noindex,nofollow" />'], result
|
['<meta name="robots" content="noindex,nofollow" />'], result
|
||||||
)
|
)
|
||||||
|
|
||||||
if not landing_page:
|
if not self._is_landing_page(url):
|
||||||
return
|
return
|
||||||
|
|
||||||
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
||||||
|
@ -144,7 +156,6 @@ class DocPageTest(ZulipTestCase):
|
||||||
expected_content: str,
|
expected_content: str,
|
||||||
extra_strings: Sequence[str] = [],
|
extra_strings: Sequence[str] = [],
|
||||||
landing_missing_strings: Sequence[str] = [],
|
landing_missing_strings: Sequence[str] = [],
|
||||||
landing_page: bool = True,
|
|
||||||
doc_html_str: bool = False,
|
doc_html_str: bool = False,
|
||||||
search_disabled: bool = False,
|
search_disabled: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -153,7 +164,6 @@ class DocPageTest(ZulipTestCase):
|
||||||
expected_content=expected_content,
|
expected_content=expected_content,
|
||||||
extra_strings=extra_strings,
|
extra_strings=extra_strings,
|
||||||
landing_missing_strings=landing_missing_strings,
|
landing_missing_strings=landing_missing_strings,
|
||||||
landing_page=landing_page,
|
|
||||||
doc_html_str=doc_html_str,
|
doc_html_str=doc_html_str,
|
||||||
search_disabled=search_disabled,
|
search_disabled=search_disabled,
|
||||||
)
|
)
|
||||||
|
@ -162,7 +172,6 @@ class DocPageTest(ZulipTestCase):
|
||||||
expected_content=expected_content,
|
expected_content=expected_content,
|
||||||
extra_strings=extra_strings,
|
extra_strings=extra_strings,
|
||||||
landing_missing_strings=landing_missing_strings,
|
landing_missing_strings=landing_missing_strings,
|
||||||
landing_page=landing_page,
|
|
||||||
doc_html_str=doc_html_str,
|
doc_html_str=doc_html_str,
|
||||||
search_disabled=search_disabled,
|
search_disabled=search_disabled,
|
||||||
)
|
)
|
||||||
|
@ -224,7 +233,6 @@ class DocPageTest(ZulipTestCase):
|
||||||
expected_content=expected_content,
|
expected_content=expected_content,
|
||||||
extra_strings=[],
|
extra_strings=[],
|
||||||
landing_missing_strings=[],
|
landing_missing_strings=[],
|
||||||
landing_page=True,
|
|
||||||
doc_html_str=True,
|
doc_html_str=True,
|
||||||
search_disabled=False,
|
search_disabled=False,
|
||||||
)
|
)
|
||||||
|
@ -249,15 +257,13 @@ class DocPageTest(ZulipTestCase):
|
||||||
self.assertEqual(result.status_code, 404)
|
self.assertEqual(result.status_code, 404)
|
||||||
|
|
||||||
def test_dev_environment_endpoints(self) -> None:
|
def test_dev_environment_endpoints(self) -> None:
|
||||||
self._test("/devlogin/", "Normal users", landing_page=False)
|
self._test("/devlogin/", "Normal users")
|
||||||
self._test("/devtools/", "Useful development URLs", landing_page=False)
|
self._test("/devtools/", "Useful development URLs")
|
||||||
self._test(
|
self._test("/emails/", "manually generate most of the emails by clicking")
|
||||||
"/emails/", "manually generate most of the emails by clicking", landing_page=False
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_error_endpoints(self) -> None:
|
def test_error_endpoints(self) -> None:
|
||||||
self._test("/errors/404/", "Page not found", landing_page=False)
|
self._test("/errors/404/", "Page not found")
|
||||||
self._test("/errors/5xx/", "Internal server error", landing_page=False)
|
self._test("/errors/5xx/", "Internal server error")
|
||||||
|
|
||||||
def test_corporate_portico_endpoints(self) -> None:
|
def test_corporate_portico_endpoints(self) -> None:
|
||||||
self._test("/team/", "industry veterans")
|
self._test("/team/", "industry veterans")
|
||||||
|
|
Loading…
Reference in New Issue