test_integrations: Improve test_no_missing_screenshot_path.

Previously, the test would fail at the first missing occurrence, and
not report about any other missing files.
Now, all missing cases are collected and presented together in a single
error message, every run.
This commit is contained in:
Niloth P
2025-05-30 15:45:35 +05:30
committed by Tim Abbott
parent 7b5e4db7ee
commit 0048902853

View File

@@ -51,27 +51,29 @@ class IntegrationsTestCase(ZulipTestCase):
self.assertFalse(missing_webhooks, message) self.assertFalse(missing_webhooks, message)
def test_no_missing_screenshot_path(self) -> None: def test_no_missing_screenshot_path(self) -> None:
message = ( message = '"{path}" does not exist for integration {integration_name}.\n'
'"{path}" does not exist for webhook {webhook_name}.\n' tip = '\nConsider updating zerver.lib.integrations.DOC_SCREENSHOT_CONFIG\n and running "tools/screenshots/generate-integration-docs-screenshot" to keep the screenshots up-to-date.'
"Consider updating zerver.lib.integrations.DOC_SCREENSHOT_CONFIG\n" error_message = ""
'and running "tools/screenshots/generate-integration-docs-screenshot" to keep the screenshots up-to-date.'
) for integration_name, screenshot_configs in WEBHOOK_SCREENSHOT_CONFIG.items():
for integration_name in WEBHOOK_SCREENSHOT_CONFIG: for screenshot_config in screenshot_configs:
configs = WEBHOOK_SCREENSHOT_CONFIG[integration_name]
for screenshot_config in configs:
integration = INTEGRATIONS[integration_name] integration = INTEGRATIONS[integration_name]
assert isinstance(integration, WebhookIntegration) assert isinstance(integration, WebhookIntegration)
if screenshot_config.fixture_name == "": if screenshot_config.fixture_name == "":
# Such screenshot configs only use a placeholder # Skip screenshot configs of webhooks with a placeholder fixture_name
# fixture_name.
continue continue
fixture_path = get_fixture_path(integration, screenshot_config) fixture_path = get_fixture_path(integration, screenshot_config)
self.assertTrue( error_message = (
os.path.isfile(fixture_path), error_message
message.format(path=fixture_path, webhook_name=integration_name), + message.format(path=fixture_path, integration_name=integration_name)
if not os.path.isfile(fixture_path)
else error_message
) )
image_path = get_image_path(integration, screenshot_config) image_path = get_image_path(integration, screenshot_config)
self.assertTrue( error_message = (
os.path.isfile(image_path), error_message
message.format(path=image_path, webhook_name=integration_name), + message.format(path=image_path, integration_name=integration_name)
if not os.path.isfile(image_path)
else error_message
) )
self.assertEqual(error_message, "", tip)