Skip to content

chore(notif-platform): More utility on NotificationProvider #93562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 18, 2025

Conversation

leeandher
Copy link
Member

Adds a few things to NotificationProvider

  • get_renderer() -> uses the default renderer by default
  • target_class -> must be a subclass of NotificationTarget, added a test for this
  • target_resource_types -> a list of valid resources that this provider can consume
  • validate_target -> a method for the eventual NotificationService to validate the incoming target

The NotificationTarget classes are dataclasses with their own validation. Even though it's a side-effect, I think it's reasonable to prevent initializing a dataclass which will produce an error if used, though I added a todo about a making needless RPC calls

All of the validation has added tests, and the renderers/providers being stubbed out have also been expanded.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 13, 2025
@leeandher leeandher force-pushed the leander/eco-710-implement-a-base-notificationtarget branch from e51544f to 77da153 Compare June 13, 2025 21:18
Copy link

codecov bot commented Jun 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #93562      +/-   ##
==========================================
+ Coverage   85.65%   88.03%   +2.38%     
==========================================
  Files       10331    10336       +5     
  Lines      596435   596434       -1     
  Branches    23161    23124      -37     
==========================================
+ Hits       510869   525088   +14219     
+ Misses      85107    70853   -14254     
- Partials      459      493      +34     

@leeandher leeandher marked this pull request as ready for review June 16, 2025 16:18
@leeandher leeandher requested review from a team as code owners June 16, 2025 16:18
Comment on lines 7 to 22
)
from sentry.testutils.cases import TestCase


class DiscordRendererTest(TestCase):
def test_default_renderer(self):
renderer = DiscordNotificationProvider.get_renderer(type=NotificationType.DEBUG)
assert renderer.render(data={}, template={}) == {}


class DiscordNotificationProviderTest(TestCase):
def test_basic_fields(self):
provider = DiscordNotificationProvider()
assert provider.key == NotificationProviderKey.DISCORD
assert provider.target_class == IntegrationNotificationTarget
assert provider.target_resource_types == [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏼

@leeandher leeandher force-pushed the leander/eco-710-implement-a-base-notificationtarget branch from 8b67558 to 8664528 Compare June 17, 2025 16:51
@leeandher leeandher requested a review from GabeVillalobos June 17, 2025 16:52
@leeandher leeandher merged commit 480e641 into master Jun 18, 2025
64 checks passed
@leeandher leeandher deleted the leander/eco-710-implement-a-base-notificationtarget branch June 18, 2025 16:35
andrewshie-sentry pushed a commit that referenced this pull request Jun 19, 2025
Adds a few things to NotificationProvider
- get_renderer() -> uses the default renderer by default
- target_class -> must be a subclass of `NotificationTarget`, added a
test for this
- target_resource_types -> a list of valid resources that this provider
can consume
- validate_target -> a method for the eventual NotificationService to
validate the incoming target


The NotificationTarget classes are dataclasses with their own
validation. Even though it's a side-effect, I think it's reasonable to
prevent initializing a dataclass which will produce an error if used,
though I added a todo about a making needless RPC calls

All of the validation has added tests, and the renderers/providers being
stubbed out have also been expanded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants