From af11ddb3cf2d0bf69de982963aef3d369a1c9141 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 30 Jun 2023 21:01:00 +0000 Subject: [PATCH] doc tests: Mock html_to_text. This shaves a couple seconds off an expensive test. --- zerver/tests/test_docs.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index 7502236734..2cdb91f496 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -203,12 +203,19 @@ class DocPageTest(ZulipTestCase): del content[url] else: # TODO: Just fill out dictionary for all ~110 endpoints - expected_strings = [] + # with some specific data from the page. + expected_strings = ["This is an API doc"] - self._test( - url=url, - expected_strings=expected_strings, - ) + # Mock OpenGraph call purely to speed up these tests. + with mock.patch( + "zerver.lib.html_to_text.html_to_text", return_value="This is an API doc" + ) as m: + self._test( + url=url, + expected_strings=expected_strings, + ) + if url != "/api/": + m.assert_called() # Make sure we exercised all content checks. self.assert_length(content, 0)