12
12
13
13
14
14
class UserSplayTest (tests .PromgenTest ):
15
+ def setUp (self ):
16
+ self .user = self .force_login (username = "demo" )
17
+
15
18
@override_settings (PROMGEN = tests .SETTINGS )
16
19
@override_settings (CELERY_TASK_ALWAYS_EAGER = True )
17
20
@mock .patch ("promgen.notification.email.send_mail" )
18
21
@mock .patch ("promgen.util.post" )
19
22
def test_user_splay (self , mock_email , mock_post ):
20
23
one = models .Service .objects .get (pk = 1 )
21
24
22
- NotificationUser .create (obj = one , value = one .owner .username )
23
- NotificationLineNotify .create (obj = one .owner , value = "#foo" )
24
- NotificationEmail .
create (
obj = one .
owner ,
value = "[email protected] " )
25
+ NotificationUser .create (obj = one , value = one .owner .username , owner = self . user )
26
+ NotificationLineNotify .create (obj = one .owner , value = "#foo" , owner = self . user )
27
+ NotificationEmail .
create (
obj = one .
owner ,
value = "[email protected] " , owner = self . user )
25
28
26
29
response = self .fireAlert ()
27
30
self .assertRoute (response , rest .AlertReceiver , 202 )
@@ -41,8 +44,8 @@ def test_failed_user(self, mock_email):
41
44
# The invalid one should be skipped while still letting
42
45
# the valid one pass
43
46
one = models .Service .objects .get (pk = 1 )
44
- NotificationEmail .
create (
obj = one ,
value = "[email protected] " )
45
- NotificationUser .create (obj = one , value = "does not exist" )
47
+ NotificationEmail .
create (
obj = one ,
value = "[email protected] " , owner = self . user )
48
+ NotificationUser .create (obj = one , value = "does not exist" , owner = self . user )
46
49
47
50
response = self .fireAlert ()
48
51
self .assertRoute (response , rest .AlertReceiver , 202 )
@@ -58,11 +61,15 @@ def test_enabled(self, mock_email):
58
61
one = models .Service .objects .get (pk = 1 )
59
62
60
63
# This notification is direct and disabled
61
- NotificationEmail .
create (
obj = one ,
value = "[email protected] " ,
enabled = False )
64
+ NotificationEmail .create (
65
+ obj = one ,
value = "[email protected] " ,
enabled = False ,
owner = self .
user
66
+ )
62
67
# Our parent notification is enabled
63
- NotificationUser .create (obj = one , value = one .owner .username )
68
+ NotificationUser .create (obj = one , value = one .owner .username , owner = self . user )
64
69
# But the child notifier is disabled and shouldn't fire
65
- NotificationEmail .
create (
obj = one .
owner ,
value = "[email protected] " ,
enabled = False )
70
+ NotificationEmail .create (
71
+ obj = one .
owner ,
value = "[email protected] " ,
enabled = False ,
owner = self .
user
72
+ )
66
73
67
74
response = self .fireAlert ()
68
75
self .assertRoute (response , rest .AlertReceiver , 202 )
0 commit comments