2424from ietf .doc .factories import DocumentFactory , WgDraftFactory , IndividualDraftFactory
2525from ietf .doc .models import ( Document , DocAlias , DocEvent , State ,
2626 BallotPositionDocEvent , DocumentAuthor , SubmissionDocEvent )
27- from ietf .doc .utils import create_ballot_if_not_open , can_edit_docextresources
27+ from ietf .doc .utils import create_ballot_if_not_open , can_edit_docextresources , update_action_holders
2828from ietf .group .factories import GroupFactory , RoleFactory
2929from ietf .group .models import Group
3030from ietf .group .utils import setup_default_community_list_for_group
@@ -479,6 +479,14 @@ def test_submit_new_wg_with_extresources(self):
479479
480480 def submit_existing (self , formats , change_authors = True , group_type = 'wg' , stream_type = 'ietf' ):
481481 # submit new revision of existing -> supply submitter info -> prev authors confirm
482+
483+ def _assert_authors_are_action_holders (draft , expect = True ):
484+ for author in draft .authors ():
485+ if expect :
486+ self .assertIn (author , draft .action_holders .all ())
487+ else :
488+ self .assertNotIn (author , draft .action_holders .all ())
489+
482490 if stream_type == 'ietf' :
483491 ad = Person .objects .get (user__username = 'ad' )
484492 if group_type == 'area' :
@@ -489,10 +497,18 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
489497 RoleFactory (name_id = 'ad' ,group = area ,person = ad )
490498 group = GroupFactory (type_id = group_type , parent = area , acronym = 'mars' )
491499 draft = DocumentFactory (type_id = 'draft' , group = group , stream_id = stream_type , ad = ad , authors = PersonFactory .create_batch (1 ))
492- draft .set_state (State .objects .get (type_id = 'draft-stream-ietf' ,slug = 'wg-doc' ))
500+ wg_doc_state = State .objects .get (type_id = 'draft-stream-ietf' ,slug = 'wg-doc' )
501+ draft .set_state (wg_doc_state )
502+ update_action_holders (draft , new_state = wg_doc_state )
493503
494504 # pretend IANA reviewed it
495- draft .set_state (State .objects .get (used = True , type = "draft-iana-review" , slug = "not-ok" ))
505+ not_ok_state = State .objects .get (used = True , type = "draft-iana-review" , slug = "not-ok" )
506+ draft .set_state (not_ok_state )
507+ update_action_holders (
508+ draft ,
509+ prev_state = State .objects .get (used = True , type = "draft-iana-review" , slug = "changed" ),
510+ new_state = not_ok_state ,
511+ )
496512
497513 # pretend it was approved to check that we notify the RFC Editor
498514 e = DocEvent (type = "iesg_approved" , doc = draft , rev = draft .rev )
@@ -531,6 +547,7 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
531547
532548 # Set the revision needed tag
533549 draft .tags .add ("need-rev" )
550+ update_action_holders (draft , new_tags = draft .tags .all ())
534551
535552 name = draft .name
536553 rev = "%02d" % (int (draft .rev ) + 1 )
@@ -542,9 +559,12 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
542559 f .write ("a" * 2000 )
543560
544561 old_docevents = list (draft .docevent_set .all ())
562+ _assert_authors_are_action_holders (draft , True ) # authors should be action holders prior to the test
545563
546564 status_url , author = self .do_submission (name , rev , group , formats , author = prev_author .person )
547565
566+ _assert_authors_are_action_holders (draft , True ) # still waiting for author confirmation
567+
548568 # supply submitter info, then previous authors get a confirmation email
549569 mailbox_before = len (outbox )
550570 r = self .supply_extra_metadata (name , status_url , "Submitter Name" , "submitter@example.com" , replaces = "" )
@@ -553,6 +573,7 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
553573 r = self .client .get (status_url )
554574 self .assertEqual (r .status_code , 200 )
555575 self .assertContains (r , "The submission is pending approval by the authors" )
576+ _assert_authors_are_action_holders (draft , True ) # still waiting for author confirmation
556577
557578 self .assertEqual (len (outbox ), mailbox_before + 1 )
558579 confirm_email = outbox [- 1 ]
@@ -592,6 +613,7 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
592613 self .assertEqual (r .status_code , 302 )
593614
594615 new_docevents = draft .docevent_set .exclude (pk__in = [event .pk for event in old_docevents ])
616+ _assert_authors_are_action_holders (draft , False ) # confirmed and posted, authors no longer hold action
595617
596618 # check we have document events
597619 doc_events = new_docevents .filter (type__in = ["new_submission" , "added_comment" ])
@@ -605,30 +627,44 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
605627 #
606628 docevents = list (new_docevents .order_by ("-time" , "-id" ))
607629 # Latest events are first (this is the default, but we make it explicit)
608- # Assert event content in chronological order:
609630
610- def inspect_docevents (docevents , event_delta , type , be_in_desc , by_name ):
611- self .assertEqual (docevents [event_delta ].type , type )
612- self .assertIn (be_in_desc , docevents [event_delta ].desc )
613- self .assertEqual (docevents [event_delta ].by .name , by_name )
631+ def inspect_docevents (docevents , event_delta , event_type , be_in_desc , by_name ):
632+ self .assertEqual (docevents [event_delta ].type , event_type ,
633+ 'Unexpected event type for event_delta={}' .format (event_delta ))
634+ self .assertIn (be_in_desc , docevents [event_delta ].desc ,
635+ 'Expected text not found for event_delta={}' .format (event_delta ))
636+ self .assertEqual (docevents [event_delta ].by .name , by_name ,
637+ 'Unexpected name for event_delta={}' .format (event_delta ))
614638 if len (docevents ) > event_delta + 1 :
615- self .assertGreater (docevents [event_delta ].id , docevents [event_delta + 1 ].id )
639+ self .assertGreater (docevents [event_delta ].id , docevents [event_delta + 1 ].id ,
640+ 'Event out of order for event_delta={}' .format (event_delta ))
616641
642+ # Assert event content in chronological order:
617643 if draft .stream_id == 'ietf' :
618- inspect_docevents (docevents , 5 , "new_submission" , "Uploaded new revision" , "Submitter Name" )
619- inspect_docevents (docevents , 4 , "new_submission" , "Request for posting confirmation" , "(System)" )
620- inspect_docevents (docevents , 3 , "new_submission" , "New version approved" , "(System)" )
621- inspect_docevents (docevents , 2 , "new_revision" , "New version available" , "Submitter Name" )
622- inspect_docevents (docevents , 1 , "changed_state" , "IANA Review" , "(System)" )
623- inspect_docevents (docevents , 0 , "changed_document" , "AD Followup" , "(System)" )
644+ expected_docevents = [
645+ ("new_submission" , "Uploaded new revision" , "Submitter Name" ),
646+ ("new_submission" , "Request for posting confirmation" , "(System)" ),
647+ ("new_submission" , "New version approved" , "(System)" ),
648+ ("new_revision" , "New version available" , "Submitter Name" ),
649+ ("changed_state" , "IANA Review" , "(System)" ),
650+ ("changed_document" , "AD Followup" , "(System)" ),
651+ ("changed_action_holders" , "IESG state changed" , "(System)" ),
652+ ]
624653 elif draft .stream_id in ('ise' , 'irtf' , 'iab' ):
625- inspect_docevents (docevents , 4 , "new_submission" , "Uploaded new revision" , "Submitter Name" )
626- inspect_docevents (docevents , 3 , "new_submission" , "Request for posting confirmation" , "(System)" )
627- inspect_docevents (docevents , 2 , "new_submission" , "New version approved" , "(System)" )
628- inspect_docevents (docevents , 1 , "new_revision" , "New version available" , "Submitter Name" )
629- inspect_docevents (docevents , 0 , "changed_document" , "tag cleared" , "(System)" )
654+ expected_docevents = [
655+ ("new_submission" , "Uploaded new revision" , "Submitter Name" ),
656+ ("new_submission" , "Request for posting confirmation" , "(System)" ),
657+ ("new_submission" , "New version approved" , "(System)" ),
658+ ("new_revision" , "New version available" , "Submitter Name" ),
659+ ("changed_document" , "tag cleared" , "(System)" ),
660+ ("changed_action_holders" , "IESG state changed" , "(System)" ),
661+ ]
630662 else :
631- pass
663+ expected_docevents = [] # empty list will skip the docevent test entirely
664+
665+ # go through event list in reverse so newest gets index 0
666+ for event_delta , (event_type , be_in_desc , by_name ) in enumerate (expected_docevents [::- 1 ]):
667+ inspect_docevents (docevents , event_delta , event_type , be_in_desc , by_name )
632668
633669 self .assertTrue (not os .path .exists (os .path .join (self .repository_dir , "%s-%s.txt" % (name , old_rev ))))
634670 self .assertTrue (os .path .exists (os .path .join (self .archive_dir , "%s-%s.txt" % (name , old_rev ))))
0 commit comments