Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
integrations: Split the getters for fixture_path and image_path.
Niloth P0b8e042627f4
diff --git a/tools/screenshots/generate-integration-docs-screenshot b/tools/screenshots/generate-integration-docs-screenshotindex cbd14c44004..feb2a844fd4 100755--- a/tools/screenshots/generate-integration-docs-screenshot+++ b/tools/screenshots/generate-integration-docs-screenshot@@ -42,7 +42,8 @@ from zerver.lib.integrations import (Integration,WebhookIntegration,WebhookScreenshotConfig,- get_fixture_and_image_paths,+ get_fixture_path,+ get_image_path,split_fixture_path,)from zerver.lib.storage import static_path@@ -220,7 +221,8 @@ def generate_screenshot_from_config() -> None:integration = INTEGRATIONS[integration_name]assert isinstance(integration, WebhookIntegration)- fixture_path, image_path = get_fixture_and_image_paths(integration, screenshot_config)+ fixture_path = get_fixture_path(integration, screenshot_config)+ image_path = get_image_path(integration, screenshot_config)bot = create_integration_bot(integration, screenshot_config.bot_name)create_integration_stream(integration, bot)if send_bot_payload_message(bot, integration, fixture_path, screenshot_config):diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.pyindex 0805d635285..c265e2c3155 100644--- a/zerver/lib/integrations.py+++ b/zerver/lib/integrations.py@@ -314,15 +314,19 @@ class WebhookScreenshotConfig:custom_headers: dict[str, str] = field(default_factory=dict)-def get_fixture_and_image_paths(+def get_fixture_path(integration: WebhookIntegration, screenshot_config: WebhookScreenshotConfig-) -> tuple[str, str]:+) -> str:fixture_dir = os.path.join("zerver", "webhooks", integration.dir_name, "fixtures")fixture_path = os.path.join(fixture_dir, screenshot_config.fixture_name)+ return fixture_path+++def get_image_path(integration: Integration, screenshot_config: WebhookScreenshotConfig) -> str:image_dir = screenshot_config.image_dir or integration.nameimage_name = screenshot_config.image_nameimage_path = os.path.join("static/images/integrations", image_dir, image_name)- return fixture_path, image_path+ return image_pathclass HubotIntegration(Integration):diff --git a/zerver/tests/test_integrations.py b/zerver/tests/test_integrations.pyindex 7c0331424ed..b77508901d6 100644--- a/zerver/tests/test_integrations.py+++ b/zerver/tests/test_integrations.py@@ -7,7 +7,8 @@ from zerver.lib.integrations import (WEBHOOK_INTEGRATIONS,WebhookIntegration,WebhookScreenshotConfig,- get_fixture_and_image_paths,+ get_fixture_path,+ get_image_path,split_fixture_path,)from zerver.lib.test_classes import ZulipTestCase@@ -24,7 +25,8 @@ class IntegrationsTestCase(ZulipTestCase):integration = INTEGRATIONS["airbrake"]assert isinstance(integration, WebhookIntegration)screenshot_config = WebhookScreenshotConfig("error_message.json", "002.png", "ci")- fixture_path, image_path = get_fixture_and_image_paths(integration, screenshot_config)+ fixture_path = get_fixture_path(integration, screenshot_config)+ image_path = get_image_path(integration, screenshot_config)self.assertEqual(fixture_path, "zerver/webhooks/airbrake/fixtures/error_message.json")self.assertEqual(image_path, "static/images/integrations/ci/002.png")@@ -63,13 +65,12 @@ class IntegrationsTestCase(ZulipTestCase):# Such screenshot configs only use a placeholder# fixture_name.continue- fixture_path, image_path = get_fixture_and_image_paths(- integration, screenshot_config- )+ fixture_path = get_fixture_path(integration, screenshot_config)self.assertTrue(os.path.isfile(fixture_path),message.format(path=fixture_path, webhook_name=integration_name),)+ image_path = get_image_path(integration, screenshot_config)self.assertTrue(os.path.isfile(image_path),message.format(path=image_path, webhook_name=integration_name),