3
3
NO_IDENTITY_MESSAGE ,
4
4
)
5
5
from sentry .models .identity import Identity
6
- from sentry .models .notificationsetting import NotificationSetting
6
+ from sentry .models .notificationsettingprovider import NotificationSettingProvider
7
7
from sentry .models .user import User
8
- from sentry .notifications .types import NotificationSettingOptionValues , NotificationSettingTypes
9
- from sentry .types .integrations import ExternalProviders
10
8
11
9
from . import BaseEventTest
12
10
@@ -27,28 +25,34 @@ def test_enable_all_slack_no_identity(self):
27
25
assert response .data ["text" ] == NO_IDENTITY_MESSAGE
28
26
29
27
def test_enable_all_slack_already_enabled (self ):
30
- NotificationSetting .objects .update_settings (
31
- ExternalProviders .EMAIL ,
32
- NotificationSettingTypes .ISSUE_ALERTS ,
33
- NotificationSettingOptionValues .NEVER ,
28
+ NotificationSettingProvider .objects .create (
34
29
user_id = self .user .id ,
30
+ scope_type = "user" ,
31
+ scope_identifier = self .user .id ,
32
+ type = "alerts" ,
33
+ provider = "slack" ,
34
+ value = "never" ,
35
35
)
36
-
37
36
response = self .post_webhook (
38
37
action_data = [{"name" : "enable_notifications" , "value" : "all_slack" }]
39
38
)
40
39
self .user = User .objects .get (id = self .user .id ) # Reload to fetch actor
41
40
assert response .status_code == 200 , response .content
42
41
assert response .data ["text" ] == ENABLE_SLACK_SUCCESS_MESSAGE
43
42
44
- assert NotificationSetting .objects .has_any_provider_settings (
45
- self .user , ExternalProviders .SLACK
43
+ assert (
44
+ NotificationSettingProvider .objects .get (
45
+ user_id = self .user .id ,
46
+ scope_type = "user" ,
47
+ scope_identifier = self .user .id ,
48
+ type = "alerts" ,
49
+ provider = "slack" ,
50
+ ).value
51
+ == "always"
46
52
)
47
53
48
54
def test_enable_all_slack (self ):
49
- assert not NotificationSetting .objects .has_any_provider_settings (
50
- self .user , ExternalProviders .SLACK
51
- )
55
+ assert not NotificationSettingProvider .objects .all ().exists ()
52
56
53
57
response = self .post_webhook (
54
58
action_data = [{"name" : "enable_notifications" , "value" : "all_slack" }]
@@ -57,6 +61,13 @@ def test_enable_all_slack(self):
57
61
assert response .status_code == 200 , response .content
58
62
assert response .data ["text" ] == ENABLE_SLACK_SUCCESS_MESSAGE
59
63
60
- assert NotificationSetting .objects .has_any_provider_settings (
61
- self .user , ExternalProviders .SLACK
64
+ assert (
65
+ NotificationSettingProvider .objects .get (
66
+ user_id = self .user .id ,
67
+ scope_type = "user" ,
68
+ scope_identifier = self .user .id ,
69
+ type = "alerts" ,
70
+ provider = "slack" ,
71
+ ).value
72
+ == "always"
62
73
)
0 commit comments