2222import amo .tests
2323import reviews
2424from abuse .models import AbuseReport
25- from access .models import GroupUser
25+ from access .models import Group , GroupUser
2626from addons .models import AddonDeviceType
2727from amo .helpers import absolutify
2828from amo .tests import (app_factory , check_links , days_ago ,
@@ -982,10 +982,6 @@ def get_app(self):
982982 return Webapp .objects .get (id = 337141 )
983983
984984 def post (self , data , queue = 'pending' ):
985- # Set some action visibility form values.
986- data ['action_visibility' ] = ('senior_reviewer' , 'reviewer' , 'staff' ,
987- 'mozilla_contact' )
988- self .create_switch (name = 'comm-dashboard' )
989985 res = self .client .post (self .url , data )
990986 self .assert3xx (res , reverse ('reviewers.apps.queue_%s' % queue ))
991987
@@ -1063,7 +1059,7 @@ def _check_thread(self):
10631059 eq_ (thread .count (), 1 )
10641060
10651061 thread = thread .get ()
1066- perms = ('senior_reviewer ' , 'reviewer' , 'staff' , 'mozilla_contact ' )
1062+ perms = ('developer ' , 'reviewer' , 'staff' )
10671063
10681064 for key in perms :
10691065 assert getattr (thread , 'read_permission_%s' % key )
@@ -1090,6 +1086,26 @@ def _check_score(self, reviewed_type):
10901086 eq_ (scores [0 ].score , amo .REVIEWED_SCORES [reviewed_type ])
10911087 eq_ (scores [0 ].note_key , reviewed_type )
10921088
1089+ def test_comm_emails (self ):
1090+ data = {'action' : 'reject' , 'comments' : 'suxor' ,
1091+ 'action_visibility' : ('developer' , 'reviewer' , 'staff' )}
1092+ data .update (self ._attachment_management_form (num = 0 ))
1093+ self .create_switch (name = 'comm-dashboard' )
1094+ self .post (data )
1095+ self ._check_thread ()
1096+
1097+ recipients = set (self .app .authors .values_list ('email' , flat = True ))
1098+ recipients .update (Group .objects .get (
1099+ name = 'App Reviewers' ).users .values_list ('email' , flat = True ))
1100+ recipients .update (Group .objects .get (
1101+ name = 'Admins' ).users .values_list ('email' , flat = True ))
1102+
1103+ recipients .remove ('editor@mozilla.com' )
1104+
1105+ eq_ (len (mail .outbox ), len (recipients ))
1106+ eq_ (mail .outbox [0 ].subject , '%s has been reviewed.' %
1107+ self .get_app ().name )
1108+
10931109 def test_xss (self ):
10941110 data = {'action' : 'comment' ,
10951111 'comments' : '<script>alert("xss")</script>' }
@@ -1120,7 +1136,6 @@ def test_pending_to_public_w_device_overrides(self):
11201136 msg = mail .outbox [0 ]
11211137 self ._check_email (msg , 'App Approved but waiting' )
11221138 self ._check_email_body (msg )
1123- self ._check_thread ()
11241139
11251140 def test_pending_to_reject_w_device_overrides (self ):
11261141 # This shouldn't be possible unless there's form hacking.
@@ -1144,7 +1159,6 @@ def test_pending_to_reject_w_device_overrides(self):
11441159 msg = mail .outbox [0 ]
11451160 self ._check_email (msg , 'Submission Update' )
11461161 self ._check_email_body (msg )
1147- self ._check_thread ()
11481162
11491163 def test_pending_to_public_w_requirements_overrides (self ):
11501164 self .create_switch (name = 'buchets' )
@@ -1209,7 +1223,6 @@ def test_pending_to_public(self, update_name, update_locales,
12091223 msg = mail .outbox [0 ]
12101224 self ._check_email (msg , 'App Approved' )
12111225 self ._check_email_body (msg )
1212- self ._check_thread ()
12131226 self ._check_score (amo .REVIEWED_WEBAPP_HOSTED )
12141227
12151228 assert update_name .called
@@ -1281,7 +1294,6 @@ def test_pending_to_public_no_mozilla_contact(self):
12811294 msg = mail .outbox [0 ]
12821295 self ._check_email (msg , 'App Approved' , with_mozilla_contact = False )
12831296 self ._check_email_body (msg )
1284- self ._check_thread ()
12851297 self ._check_score (amo .REVIEWED_WEBAPP_HOSTED )
12861298
12871299 @mock .patch ('addons.tasks.index_addons' )
@@ -1306,7 +1318,6 @@ def test_pending_to_public_waiting(self, update_name, update_locales,
13061318 msg = mail .outbox [0 ]
13071319 self ._check_email (msg , 'App Approved but waiting' )
13081320 self ._check_email_body (msg )
1309- self ._check_thread ()
13101321 self ._check_score (amo .REVIEWED_WEBAPP_HOSTED )
13111322
13121323 assert not update_name .called
@@ -1340,7 +1351,6 @@ def test_pending_to_reject(self):
13401351 msg = mail .outbox [0 ]
13411352 self ._check_email (msg , 'Submission Update' )
13421353 self ._check_email_body (msg )
1343- self ._check_thread ()
13441354 self ._check_score (amo .REVIEWED_WEBAPP_HOSTED )
13451355
13461356 def test_multiple_versions_reject_hosted (self ):
@@ -1394,7 +1404,6 @@ def test_pending_to_escalation(self):
13941404 self ._check_email (dev_msg , 'Submission Update' )
13951405 adm_msg = mail .outbox [1 ]
13961406 self ._check_admin_email (adm_msg , 'Escalated Review Requested' )
1397- self ._check_thread ()
13981407
13991408 def test_pending_to_disable_senior_reviewer (self ):
14001409 self .login_as_senior_reviewer ()
@@ -1409,7 +1418,6 @@ def test_pending_to_disable_senior_reviewer(self):
14091418 self ._check_log (amo .LOG .APP_DISABLED )
14101419 eq_ (len (mail .outbox ), 1 )
14111420 self ._check_email (mail .outbox [0 ], 'App disabled by reviewer' )
1412- self ._check_thread ()
14131421
14141422 def test_pending_to_disable (self ):
14151423 self .app .update (status = amo .STATUS_PUBLIC )
@@ -1438,7 +1446,6 @@ def test_escalation_to_public(self):
14381446 msg = mail .outbox [0 ]
14391447 self ._check_email (msg , 'App Approved' )
14401448 self ._check_email_body (msg )
1441- self ._check_thread ()
14421449
14431450 def test_escalation_to_reject (self ):
14441451 EscalationQueue .objects .create (addon = self .app )
@@ -1457,7 +1464,6 @@ def test_escalation_to_reject(self):
14571464 eq_ (len (mail .outbox ), 1 )
14581465 msg = mail .outbox [0 ]
14591466 self ._check_email (msg , 'Submission Update' )
1460- self ._check_thread ()
14611467 self ._check_email_body (msg )
14621468 self ._check_score (amo .REVIEWED_WEBAPP_HOSTED )
14631469
@@ -1476,7 +1482,6 @@ def test_escalation_to_disable_senior_reviewer(self):
14761482 eq_ (EscalationQueue .objects .count (), 0 )
14771483 eq_ (len (mail .outbox ), 1 )
14781484 self ._check_email (mail .outbox [0 ], 'App disabled by reviewer' )
1479- self ._check_thread ()
14801485
14811486 def test_escalation_to_disable (self ):
14821487 EscalationQueue .objects .create (addon = self .app )
@@ -1517,7 +1522,6 @@ def test_rereview_to_reject(self):
15171522 self ._check_email (msg , 'Submission Update' )
15181523 self ._check_email_body (msg )
15191524 self ._check_score (amo .REVIEWED_WEBAPP_REREVIEW )
1520- self ._check_thread ()
15211525
15221526 def test_rereview_to_disable_senior_reviewer (self ):
15231527 self .login_as_senior_reviewer ()
@@ -1533,7 +1537,6 @@ def test_rereview_to_disable_senior_reviewer(self):
15331537 eq_ (RereviewQueue .objects .filter (addon = self .app ).count (), 0 )
15341538 eq_ (len (mail .outbox ), 1 )
15351539 self ._check_email (mail .outbox [0 ], 'App disabled by reviewer' )
1536- self ._check_thread ()
15371540
15381541 def test_rereview_to_disable (self ):
15391542 RereviewQueue .objects .create (addon = self .app )
@@ -1572,7 +1575,6 @@ def test_rereview_to_escalation(self):
15721575 self ._check_email (dev_msg , 'Submission Update' )
15731576 adm_msg = mail .outbox [1 ]
15741577 self ._check_admin_email (adm_msg , 'Escalated Review Requested' )
1575- self ._check_thread ()
15761578
15771579 def test_more_information (self ):
15781580 # Test the same for all queues.
@@ -1607,7 +1609,6 @@ def test_comment(self):
16071609 self .post (data )
16081610 eq_ (len (mail .outbox ), 0 )
16091611 self ._check_log (amo .LOG .COMMENT_VERSION )
1610- self ._check_thread ()
16111612
16121613 def test_receipt_no_node (self ):
16131614 res = self .client .get (self .url )
0 commit comments