Skip to content

Commit c11b2be

Browse files
authored
fix(integrations): Correctly import MSTeams provider (#102973)
Was accidentally removed in #99433, adds it back and tests for it (and a small edit to import structure) Fixes [SENTRY-54V3](https://sentry.sentry.io/issues/6881966284/events/cf3fce57b76048ea88be2a7d57c7c502/)
1 parent 7bb5349 commit c11b2be

File tree

5 files changed

+42
-11
lines changed

5 files changed

+42
-11
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from sentry.integrations.msteams.spec import MsTeamsMessagingSpec
22

33
from .handlers import MSTeamsActionHandler # noqa: F401,F403
4+
from .notifications import * # noqa: F401,F403
45

56
MsTeamsMessagingSpec().initialize()

src/sentry/notifications/apps.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@ class Config(AppConfig):
55
name = "sentry.notifications"
66

77
def ready(self) -> None:
8-
import sentry.notifications.platform.sample # NOQA
9-
10-
# Register the NotificationProviders for the platform
11-
from sentry.notifications.platform.discord.provider import ( # NOQA
12-
DiscordNotificationProvider,
13-
)
14-
from sentry.notifications.platform.email.provider import EmailNotificationProvider # NOQA
15-
from sentry.notifications.platform.msteams.provider import ( # NOQA
16-
MSTeamsNotificationProvider,
17-
)
18-
from sentry.notifications.platform.slack.provider import SlackNotificationProvider # NOQA
8+
# Register the providers and templates for the new platform
9+
import sentry.notifications.platform.discord.provider # noqa: F401
10+
import sentry.notifications.platform.email.provider # noqa: F401
11+
import sentry.notifications.platform.msteams.provider # noqa: F401
12+
import sentry.notifications.platform.slack.provider # noqa: F401
13+
import sentry.notifications.platform.templates # noqa: F401
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# All templates should be imported here so they are registered in the notifications Django app.
2+
# See sentry/notifications/apps.py
3+
4+
from .sample import * # noqa: F401,F403
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from sentry.integrations.types import ExternalProviders
2+
from sentry.notifications.platform.types import NotificationProviderKey
3+
from sentry.testutils.cases import TestCase
4+
5+
6+
class NotificationsDjangoAppTest(TestCase):
7+
8+
def test_registers_legacy_providers(self) -> None:
9+
"""
10+
This django app doesn't actually register these legacy providers because it would result
11+
in some circular breakages from all the __init__.py imports. We'll still test it here
12+
to make sure it doesn't break in the future.
13+
14+
If this test is failing for you, ensure all `@register_notification_provider` decorators
15+
are triggered by an initialization import.
16+
"""
17+
from sentry.notifications.notify import registry
18+
19+
assert len(registry) == 3
20+
assert registry[ExternalProviders.EMAIL] is not None
21+
assert registry[ExternalProviders.SLACK] is not None
22+
assert registry[ExternalProviders.MSTEAMS] is not None
23+
24+
def test_registers_platform_providers(self) -> None:
25+
from sentry.notifications.platform.registry import provider_registry
26+
27+
assert len(provider_registry.registrations) == 4
28+
assert provider_registry.get(NotificationProviderKey.DISCORD) is not None
29+
assert provider_registry.get(NotificationProviderKey.EMAIL) is not None
30+
assert provider_registry.get(NotificationProviderKey.MSTEAMS) is not None
31+
assert provider_registry.get(NotificationProviderKey.SLACK) is not None

0 commit comments

Comments
 (0)