File tree Expand file tree Collapse file tree 5 files changed +42
-11
lines changed
tests/sentry/notifications Expand file tree Collapse file tree 5 files changed +42
-11
lines changed Original file line number Diff line number Diff line change 11from sentry .integrations .msteams .spec import MsTeamsMessagingSpec
22
33from .handlers import MSTeamsActionHandler # noqa: F401,F403
4+ from .notifications import * # noqa: F401,F403
45
56MsTeamsMessagingSpec ().initialize ()
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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
File renamed without changes.
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments