@@ -413,26 +413,44 @@ def test_edit_ballot_rfceditornote(self):
413413
414414 def test_issue_ballot (self ):
415415 ad = Person .objects .get (user__username = "ad" )
416- draft = IndividualDraftFactory (ad = ad )
417- url = urlreverse ('ietf.doc.views_ballot.ballot_writeupnotes' , kwargs = dict (name = draft .name ))
418- login_testing_unauthorized (self , "ad" , url )
419-
420-
421- empty_outbox ()
422-
423- r = self .client .post (url , dict (
424- ballot_writeup = "This is a test." ,
425- issue_ballot = "1" ))
426- self .assertEqual (r .status_code , 200 )
427- draft = Document .objects .get (name = draft .name )
416+ for case in ('none' ,'past' ,'future' ):
417+ draft = IndividualDraftFactory (ad = ad )
418+ if case in ('past' ,'future' ):
419+ LastCallDocEvent .objects .create (
420+ by = Person .objects .get (name = '(System)' ),
421+ type = 'sent_last_call' ,
422+ doc = draft ,
423+ rev = draft .rev ,
424+ desc = 'issued last call' ,
425+ expires = datetime .datetime .now ()+ datetime .timedelta (days = 1 if case == 'future' else - 1 )
426+ )
427+ url = urlreverse ('ietf.doc.views_ballot.ballot_writeupnotes' , kwargs = dict (name = draft .name ))
428+ login_testing_unauthorized (self , "ad" , url )
429+
430+
431+ empty_outbox ()
432+
433+ r = self .client .post (url , dict (
434+ ballot_writeup = "This is a test." ,
435+ issue_ballot = "1" ))
436+ self .assertEqual (r .status_code , 200 )
437+ draft = Document .objects .get (name = draft .name )
438+
439+ self .assertTrue (draft .latest_event (type = "sent_ballot_announcement" ))
440+ self .assertEqual (len (outbox ), 2 )
441+ self .assertTrue ('Ballot issued:' in outbox [- 2 ]['Subject' ])
442+ self .assertTrue ('iesg@' in outbox [- 2 ]['To' ])
443+ self .assertTrue ('Ballot issued:' in outbox [- 1 ]['Subject' ])
444+ self .assertTrue ('drafts-eval@' in outbox [- 1 ]['To' ])
445+ self .assertTrue ('X-IETF-Draft-string' in outbox [- 1 ])
446+ if case == 'none' :
447+ self .assertNotIn ('call expire' , outbox [- 1 ].get_payload (decode = True ).decode ("utf-8" ))
448+ elif case == 'past' :
449+ self .assertIn ('call expired' , outbox [- 1 ].get_payload (decode = True ).decode ("utf-8" ))
450+ else :
451+ self .assertIn ('call expires' , outbox [- 1 ].get_payload (decode = True ).decode ("utf-8" ))
452+ self .client .logout ()
428453
429- self .assertTrue (draft .latest_event (type = "sent_ballot_announcement" ))
430- self .assertEqual (len (outbox ), 2 )
431- self .assertTrue ('Ballot issued:' in outbox [- 2 ]['Subject' ])
432- self .assertTrue ('iesg@' in outbox [- 2 ]['To' ])
433- self .assertTrue ('Ballot issued:' in outbox [- 1 ]['Subject' ])
434- self .assertTrue ('drafts-eval@' in outbox [- 1 ]['To' ])
435- self .assertTrue ('X-IETF-Draft-string' in outbox [- 1 ])
436454
437455 def test_edit_approval_text (self ):
438456 ad = Person .objects .get (user__username = "ad" )
0 commit comments