@@ -83,6 +83,7 @@ def test_change_state(self):
8383
8484 # change state
8585 comments_before = draft .idinternal .comments ().count ()
86+ mailbox_before = len (mail_outbox )
8687
8788 r = self .client .post (url ,
8889 dict (state = "12" , substate = "" ))
@@ -95,9 +96,9 @@ def test_change_state(self):
9596 self .assertEquals (draft .idinternal .cur_sub_state , None )
9697 self .assertEquals (draft .idinternal .comments ().count (), comments_before + 1 )
9798 self .assertTrue ("State changed" in draft .idinternal .comments ()[0 ].comment_text )
98- self .assertTrue (len (mail_outbox ) == 2 )
99- self .assertTrue ("State Update Notice" in mail_outbox [0 ]['Subject' ])
100- self .assertTrue (draft .filename in mail_outbox [1 ]['Subject' ])
99+ self .assertEquals (len (mail_outbox ), mailbox_before + 2 )
100+ self .assertTrue ("State Update Notice" in mail_outbox [- 2 ]['Subject' ])
101+ self .assertTrue (draft .filename in mail_outbox [- 1 ]['Subject' ])
101102
102103
103104 def test_make_last_call (self ):
@@ -106,6 +107,8 @@ def test_make_last_call(self):
106107 self .client .login (remote_user = "klm" )
107108 url = urlreverse ('doc_change_state' , kwargs = dict (name = draft .filename ))
108109
110+ mailbox_before = len (mail_outbox )
111+
109112 self .assertRaises (BallotInfo .DoesNotExist , lambda : draft .idinternal .ballot )
110113 r = self .client .post (url ,
111114 dict (state = "15" , substate = "" ))
@@ -125,7 +128,7 @@ def test_make_last_call(self):
125128 self .assertTrue ("Technical Summary" in draft .idinternal .ballot .ballot_writeup )
126129
127130 # mail notice
128- self .assertTrue (mail_outbox )
131+ self .assertTrue (len ( mail_outbox ) > mailbox_before )
129132 self .assertTrue ("Last Call:" in mail_outbox [- 1 ]['Subject' ])
130133
131134 # comment
@@ -157,6 +160,7 @@ def test_edit_info(self):
157160
158161 # edit info
159162 comments_before = draft .idinternal .comments ().count ()
163+ mailbox_before = len (mail_outbox )
160164 draft .group = Acronym .objects .get (acronym_id = Acronym .INDIVIDUAL_SUBMITTER )
161165 draft .save ()
162166 new_job_owner = IESGLogin .objects .exclude (id__in = [IESGLogin .objects .get (login_name = "klm" ).id , draft .idinternal .job_owner_id ])[0 ]
@@ -180,10 +184,9 @@ def test_edit_info(self):
180184 self .assertEquals (draft .idinternal .job_owner , new_job_owner )
181185 self .assertEquals (draft .idinternal .note , "" )
182186 self .assertTrue (not draft .idinternal .agenda )
183- self .assertEquals (draft .idinternal .comments ().count (), comments_before + 2 )
184- self .assertTrue ("cleared" in draft .idinternal .comments ()[0 ].comment_text )
185- self .assertTrue (len (mail_outbox ) == 1 )
186- self .assertTrue (draft .filename in mail_outbox [0 ]['Subject' ])
187+ self .assertEquals (draft .idinternal .comments ().count (), comments_before + 3 )
188+ self .assertEquals (len (mail_outbox ), mailbox_before + 1 )
189+ self .assertTrue (draft .filename in mail_outbox [- 1 ]['Subject' ])
187190
188191
189192class RequestResurrectTestCase (django .test .TestCase ):
@@ -208,6 +211,7 @@ def test_request_resurrect(self):
208211
209212 # request resurrect
210213 comments_before = draft .idinternal .comments ().count ()
214+ mailbox_before = len (mail_outbox )
211215
212216 r = self .client .post (url , dict ())
213217 self .assertEquals (r .status_code , 302 )
@@ -216,8 +220,8 @@ def test_request_resurrect(self):
216220 self .assertEquals (draft .idinternal .resurrect_requested_by , IESGLogin .objects .get (login_name = login_as ))
217221 self .assertEquals (draft .idinternal .comments ().count (), comments_before + 1 )
218222 self .assertTrue ("Resurrection" in draft .idinternal .comments ()[0 ].comment_text )
219- self .assertTrue (len (mail_outbox ) == 1 )
220- self .assertTrue ("Resurrection" in mail_outbox [0 ]['Subject' ])
223+ self .assertEquals (len (mail_outbox ), mailbox_before + 1 )
224+ self .assertTrue ("Resurrection" in mail_outbox [- 1 ]['Subject' ])
221225
222226class AddCommentTestCase (django .test .TestCase ):
223227 fixtures = ['base' , 'draft' ]
@@ -235,15 +239,16 @@ def test_add_comment(self):
235239
236240 # request resurrect
237241 comments_before = draft .idinternal .comments ().count ()
242+ mailbox_before = len (mail_outbox )
238243
239244 r = self .client .post (url , dict (comment = "This is a test." ))
240245 self .assertEquals (r .status_code , 302 )
241246
242247 self .assertEquals (draft .idinternal .comments ().count (), comments_before + 1 )
243248 self .assertTrue ("This is a test." in draft .idinternal .comments ()[0 ].comment_text )
244- self .assertTrue (len (mail_outbox ) == 1 )
245- self .assertTrue ("updated" in mail_outbox [0 ]['Subject' ])
246- self .assertTrue (draft .filename in mail_outbox [0 ]['Subject' ])
249+ self .assertEquals (len (mail_outbox ), mailbox_before + 1 )
250+ self .assertTrue ("updated" in mail_outbox [- 1 ]['Subject' ])
251+ self .assertTrue (draft .filename in mail_outbox [- 1 ]['Subject' ])
247252
248253class EditPositionTestCase (django .test .TestCase ):
249254 fixtures = ['base' , 'draft' , 'ballot' ]
@@ -303,6 +308,7 @@ def test_send_ballot_comment(self):
303308 self .assertTrue (len (q ('form input[name="cc"]' )) > 0 )
304309
305310 # send
311+ mailbox_before = len (mail_outbox )
306312 IESGComment .objects .create (ballot = draft .idinternal .ballot ,
307313 ad = IESGLogin .objects .get (login_name = login_as ),
308314 text = "Test!" , date = date .today (),
@@ -311,8 +317,58 @@ def test_send_ballot_comment(self):
311317 r = self .client .post (url , dict (cc = "test@example.com" , cc_state_change = "1" ))
312318 self .assertEquals (r .status_code , 302 )
313319
314- self .assertTrue (len (mail_outbox ) == 1 )
315- self .assertTrue ("COMMENT" in mail_outbox [0 ]['Subject' ])
320+ self .assertEquals (len (mail_outbox ), mailbox_before + 1 )
321+ self .assertTrue ("COMMENT" in mail_outbox [- 1 ]['Subject' ])
322+
323+
324+ class DeferBallotTestCase (django .test .TestCase ):
325+ fixtures = ['base' , 'draft' , 'ballot' ]
326+
327+ def test_defer_ballot (self ):
328+ draft = InternetDraft .objects .get (filename = "draft-ietf-mipshop-pfmipv6" )
329+ url = urlreverse ('doc_defer_ballot' , kwargs = dict (name = draft .filename ))
330+ login_testing_unauthorized (self , "rhousley" , url )
331+
332+ # normal get
333+ r = self .client .get (url )
334+ self .assertEquals (r .status_code , 200 )
335+
336+ # defer
337+ self .assertTrue (not draft .idinternal .ballot .defer )
338+ mailbox_before = len (mail_outbox )
339+
340+ r = self .client .post (url , dict ())
341+ self .assertEquals (r .status_code , 302 )
342+
343+ draft = InternetDraft .objects .get (filename = "draft-ietf-mipshop-pfmipv6" )
344+ self .assertTrue (draft .idinternal .ballot .defer )
345+ self .assertTrue (draft .idinternal .cur_state_id == IDState .IESG_EVALUATION_DEFER )
346+
347+ self .assertEquals (len (mail_outbox ), mailbox_before + 2 )
348+ self .assertTrue ("Deferred" in mail_outbox [- 2 ]['Subject' ])
349+ self .assertTrue (draft .file_tag () in mail_outbox [- 2 ]['Subject' ])
350+
351+ def test_undefer_ballot (self ):
352+ draft = InternetDraft .objects .get (filename = "draft-ietf-mipshop-pfmipv6" )
353+ url = urlreverse ('doc_undefer_ballot' , kwargs = dict (name = draft .filename ))
354+ login_testing_unauthorized (self , "rhousley" , url )
355+
356+ draft .idinternal .ballot .defer = True
357+ draft .idinternal .ballot .save ()
358+
359+ # normal get
360+ r = self .client .get (url )
361+ self .assertEquals (r .status_code , 200 )
362+
363+ # undefer
364+ self .assertTrue (draft .idinternal .ballot .defer )
365+
366+ r = self .client .post (url , dict ())
367+ self .assertEquals (r .status_code , 302 )
368+
369+ draft = InternetDraft .objects .get (filename = "draft-ietf-mipshop-pfmipv6" )
370+ self .assertTrue (not draft .idinternal .ballot .defer )
371+ self .assertTrue (draft .idinternal .cur_state_id == IDState .IESG_EVALUATION )
316372
317373
318374TEST_RFC_INDEX = '''<?xml version="1.0" encoding="UTF-8"?>
0 commit comments