Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test_docs: Add test to check all images in integration docs.
Niloth P5892dac9fc49
diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.pyindex 949ba4e1784..9b8611e3c98 100644--- a/zerver/tests/test_docs.py+++ b/zerver/tests/test_docs.py@@ -321,7 +321,9 @@ class DocPageTest(ZulipTestCase):)def test_integration_doc_endpoints(self) -> None:- self._test(+ images_in_docs = set()++ response = self._test("/integrations/",expected_strings=["native integrations.",@@ -330,10 +332,16 @@ class DocPageTest(ZulipTestCase):"IFTTT",],)+ page = response.content.decode("utf-8")+ for image in re.findall(r"/static/images/integrations/(logos/.*)\"", page):+ images_in_docs.add(image)for integration in INTEGRATIONS:url = f"/integrations/doc-html/{integration}"- self._test(url, expected_strings=[])+ response = self._test(url, expected_strings=[])+ doc = response.content.decode("utf-8")+ for image in re.findall(r"/static/images/integrations/(.*)\"", doc):+ images_in_docs.add(image)result = self.client_get("/integrations/doc-html/nonexistent_integration",@@ -342,6 +350,32 @@ class DocPageTest(ZulipTestCase):)self.assertEqual(result.status_code, 404)+ directory = "static/images/integrations"+ images_in_dir = {+ image_path+ for root, _, files in os.walk(directory)+ for file in files+ if "bot_avatars"+ not in (image_path := os.path.relpath(os.path.join(root, file), directory))+ }++ self.assertEqual(+ images_in_dir,+ images_in_docs,+ (+ "\n\nThe following images are not used in documentation and can be removed:\n"+ + "\n".join(extra_images)+ if (extra_images := images_in_dir - images_in_docs)+ else ""+ )+ + (+ "\n\nThe following images are used in documentation but do not exist:\n"+ + "\n".join(missing_images)+ if (missing_images := images_in_docs - images_in_dir)+ else ""+ ),+ )+def test_integration_pages_open_graph_metadata(self) -> None:og_description = '<meta property="og:description" content="Zulip comes with over'