test_docs: Return response from DocPageTest._test.

Function call hierarchy:
`_test` -> `_check_basic_fetch` -> `get_doc` -> `client_get`

All the functions in the chain return the request returned by
`client_get`, except for `_test`.

Now, `_test` also returns the response from the URL on the root
subdomain when the ROOT_DOMAIN_LANDING_PAGE is set to False.

This enables us to re-use the fetched reponse in our test functions,
and limit each URL to a single call of `client_get`.
This commit is contained in:
Niloth P
2025-02-01 09:48:30 +05:30
committed by Tim Abbott
parent acfbf9f46b
commit ccb6c74e95

View File

@@ -86,9 +86,9 @@ class DocPageTest(ZulipTestCase):
)
return result
def _test(self, url: str, expected_strings: Sequence[str]) -> None:
def _test(self, url: str, expected_strings: Sequence[str]) -> "TestHttpResponse":
# Test the URL on the root subdomain
self._check_basic_fetch(
response = self._check_basic_fetch(
url=url,
subdomain="",
expected_strings=expected_strings,
@@ -96,7 +96,7 @@ class DocPageTest(ZulipTestCase):
)
if not self._is_landing_page(url):
return
return response
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
# Test the URL on the root subdomain with the landing page setting
@@ -119,6 +119,7 @@ class DocPageTest(ZulipTestCase):
],
result,
)
return response
def test_zephyr_disallows_robots(self) -> None:
sample_urls = [