Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sentry/integrations/msteams/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sentry.integrations.msteams.spec import MsTeamsMessagingSpec

from .handlers import MSTeamsActionHandler # noqa: F401,F403
from .notifications import * # noqa: F401,F403

MsTeamsMessagingSpec().initialize()
17 changes: 6 additions & 11 deletions src/sentry/notifications/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ class Config(AppConfig):
name = "sentry.notifications"

def ready(self) -> None:
import sentry.notifications.platform.sample # NOQA

# Register the NotificationProviders for the platform
from sentry.notifications.platform.discord.provider import ( # NOQA
DiscordNotificationProvider,
)
from sentry.notifications.platform.email.provider import EmailNotificationProvider # NOQA
from sentry.notifications.platform.msteams.provider import ( # NOQA
MSTeamsNotificationProvider,
)
from sentry.notifications.platform.slack.provider import SlackNotificationProvider # NOQA
# Register the providers and templates for the new platform
import sentry.notifications.platform.discord.provider # noqa: F401
import sentry.notifications.platform.email.provider # noqa: F401
import sentry.notifications.platform.msteams.provider # noqa: F401
import sentry.notifications.platform.slack.provider # noqa: F401
import sentry.notifications.platform.templates # noqa: F401
4 changes: 4 additions & 0 deletions src/sentry/notifications/platform/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# All templates should be imported here so they are registered in the notifications Django app.
# See sentry/notifications/apps.py

from .sample import * # noqa: F401,F403
31 changes: 31 additions & 0 deletions tests/sentry/notifications/test_apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from sentry.integrations.types import ExternalProviders
from sentry.notifications.platform.types import NotificationProviderKey
from sentry.testutils.cases import TestCase


class NotificationsDjangoAppTest(TestCase):

def test_registers_legacy_providers(self) -> None:
"""
This django app doesn't actually register these legacy providers because it would result
in some circular breakages from all the __init__.py imports. We'll still test it here
to make sure it doesn't break in the future.

If this test is failing for you, ensure all `@register_notification_provider` decorators
are triggered by an initialization import.
"""
from sentry.notifications.notify import registry

assert len(registry) == 3
assert registry[ExternalProviders.EMAIL] is not None
assert registry[ExternalProviders.SLACK] is not None
assert registry[ExternalProviders.MSTEAMS] is not None

def test_registers_platform_providers(self) -> None:
from sentry.notifications.platform.registry import provider_registry

assert len(provider_registry.registrations) == 4
assert provider_registry.get(NotificationProviderKey.DISCORD) is not None
assert provider_registry.get(NotificationProviderKey.EMAIL) is not None
assert provider_registry.get(NotificationProviderKey.MSTEAMS) is not None
assert provider_registry.get(NotificationProviderKey.SLACK) is not None
Loading