Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

integrations: Add test to verify alphabetical order of registries.

Niloth P021048ca5f77
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 2020a4e5bdf..71b12ec9616 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -955,7 +955,7 @@ WEBHOOK_INTEGRATIONS: list[WebhookIntegration] = [
),
]
-INTEGRATIONS: dict[str, Integration] = {
+OTHER_INTEGRATIONS: dict[str, Integration] = {
"asana": Integration("asana", ["project-management"]),
"big-blue-button": Integration(
"big-blue-button", ["video-calling", "communication"], display_name="BigBlueButton"
@@ -1067,6 +1067,8 @@ HUBOT_INTEGRATIONS: list[HubotIntegration] = [
),
]
+INTEGRATIONS: dict[str, Integration] = {**OTHER_INTEGRATIONS}
+
for python_api_integration in PYTHON_API_INTEGRATIONS:
INTEGRATIONS[python_api_integration.name] = python_api_integration
diff --git a/zerver/tests/test_integrations.py b/zerver/tests/test_integrations.py
index a6ef02c29e1..17265c5abe1 100644
--- a/zerver/tests/test_integrations.py
+++ b/zerver/tests/test_integrations.py
@@ -1,8 +1,16 @@
import os
from zerver.lib.integrations import (
+ BOT_INTEGRATIONS,
+ HUBOT_INTEGRATIONS,
INTEGRATIONS,
NO_SCREENSHOT_CONFIG,
+ OTHER_INTEGRATIONS,
+ PYTHON_API_INTEGRATIONS,
+ WEBHOOK_INTEGRATIONS,
+ BotIntegration,
+ HubotIntegration,
+ PythonAPIIntegration,
WebhookIntegration,
WebhookScreenshotConfig,
get_fixture_path,
@@ -106,3 +114,36 @@ class IntegrationsTestCase(ZulipTestCase):
else error_message
)
self.assertEqual(error_message, "", tip)
+
+ def test_sorting(self) -> None:
+ integration_lists: dict[
+ str,
+ list[WebhookIntegration]
+ | list[BotIntegration]
+ | list[HubotIntegration]
+ | list[PythonAPIIntegration],
+ ] = {
+ "WEBHOOK_INTEGRATIONS": WEBHOOK_INTEGRATIONS,
+ "PYTHON_API_INTEGRATIONS": PYTHON_API_INTEGRATIONS,
+ "BOT_INTEGRATIONS": BOT_INTEGRATIONS,
+ "HUBOT_INTEGRATIONS": HUBOT_INTEGRATIONS,
+ }
+
+ errors: list[str] = []
+
+ for list_name, integration_list in integration_lists.items():
+ names = [integration.name for integration in integration_list]
+ errors.extend(
+ f"{list_name} is not sorted: '{names[i]}' > '{names[i + 1]}'"
+ for i in range(len(names) - 1)
+ if names[i] > names[i + 1]
+ )
+
+ keys = list(OTHER_INTEGRATIONS.keys())
+ errors.extend(
+ f"OTHER_INTEGRATIONS dict is not sorted: '{keys[i]}' > '{keys[i + 1]}'"
+ for i in range(len(keys) - 1)
+ if keys[i] > keys[i + 1]
+ )
+
+ assert not errors, "\n".join(errors)