-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove other notification actions (#64)
* remove other notification actions details: - it has been quite a while since we only support GlobalActions - this PR removes both the helper methods to turn models into GlobalActions as well as typing references to other models - it might break existing customers using the tuned models, so the next release should communicate this properly - this PR also fixes a bunch of typing issues after running pyright on the repo - remove unused tests + use Annotated type
- Loading branch information
1 parent
24f6a0d
commit 40517b6
Showing
9 changed files
with
69 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ def test_validate(self, manager: MonitorManager) -> None: | |
assert manager.validate() | ||
|
||
def test_failing_validation(self, monitor_setup: MonitorSetup) -> None: | ||
monitor_setup.actions = [EmailRecipient(id="some_long_id", destination="[email protected]")] | ||
monitor_setup.actions = [GlobalAction(target="some_long_id")] | ||
monitor_setup.config.mode = "weird_mode" # type: ignore | ||
monitor_setup.apply() | ||
|
||
|
@@ -77,66 +77,3 @@ def test_monitor_running_eagerly(self, existing_monitor_setup: MonitorSetup) -> | |
) | ||
|
||
assert new_expected_result["allowPartialTargetBatches"] == False | ||
|
||
|
||
class TestNotificationActions(TestCase): | ||
def setUp(self) -> None: | ||
self.monitor_setup = MagicMock() | ||
self.monitor_setup.credentials.org_id = 'test_org' | ||
|
||
self.monitor_setup.monitor = MagicMock() | ||
self.monitor_setup.monitor.actions = [ | ||
SlackWebhook(id='slack1', destination='https://slack.com/webhook'), | ||
EmailRecipient(id='email1', destination='[email protected]'), | ||
GlobalAction(target="existing-pagerDuty") | ||
] | ||
|
||
self.notifications_api = MagicMock() | ||
self.notifications_api.list_notification_actions.return_value = [] | ||
|
||
self.monitor_api = MagicMock() | ||
|
||
self.monitor_manager = MonitorManager( | ||
setup = self.monitor_setup, | ||
notifications_api=self.notifications_api, | ||
monitor_api=self.monitor_api | ||
) | ||
|
||
def test_notification_actions_are_updated(self) -> None: | ||
self.monitor_manager._update_notification_actions() | ||
|
||
expected_calls = [ | ||
call( | ||
org_id='test_org', | ||
type='EMAIL', | ||
action_id='email1', | ||
body={'email': '[email protected]'} | ||
), | ||
call( | ||
org_id='test_org', | ||
type='SLACK', | ||
action_id='slack1', | ||
body={'slackWebhook': 'https://slack.com/webhook'} | ||
) | ||
] | ||
|
||
for call_args in expected_calls: | ||
assert call_args in self.notifications_api.put_notification_action.call_args_list | ||
|
||
def test_global_actions_are_made(self) -> None: | ||
self.monitor_manager._update_notification_actions() | ||
|
||
assert GlobalAction(target='existing-pagerDuty') in self.monitor_setup.monitor.actions | ||
|
||
def test_existing_notification_actions_are_fetched(self) -> None: | ||
self.monitor_manager._update_notification_actions() | ||
|
||
self.notifications_api.list_notification_actions.assert_called_once_with( | ||
org_id='test_org' | ||
) | ||
|
||
def test_error_is_raised_if_monitor_is_none(self) -> None: | ||
self.monitor_setup.monitor = None | ||
|
||
with self.assertRaises(ValueError): | ||
self.monitor_manager._update_notification_actions() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.