@@ -321,48 +321,53 @@ def text_submit_new_wg_txt_xml(self):
321321
322322 def submit_existing (self , formats , change_authors = True , group_type = 'wg' , stream_type = 'ietf' ):
323323 # submit new revision of existing -> supply submitter info -> prev authors confirm
324- # The tests expect the draft to always have an ad, but that doesn't match what happens for most streams
325- ad = Person .objects .get (user__username = 'ad' )
326- if group_type == 'area' :
327- group = GroupFactory (type_id = 'area' , acronym = 'mars' )
328- RoleFactory (name_id = 'ad' , group = group , person = ad )
329- else :
330- area = GroupFactory (type_id = 'area' )
331- RoleFactory (name_id = 'ad' ,group = area ,person = ad )
332- group = GroupFactory (type_id = group_type , parent = area , acronym = 'mars' )
333- draft = DocumentFactory (type_id = 'draft' , group = group , stream_id = stream_type , ad = ad , authors = PersonFactory .create_batch (1 ))
334324 if stream_type == 'ietf' :
325+ ad = Person .objects .get (user__username = 'ad' )
326+ if group_type == 'area' :
327+ group = GroupFactory (type_id = 'area' , acronym = 'mars' )
328+ RoleFactory (name_id = 'ad' , group = group , person = ad )
329+ else :
330+ area = GroupFactory (type_id = 'area' )
331+ RoleFactory (name_id = 'ad' ,group = area ,person = ad )
332+ group = GroupFactory (type_id = group_type , parent = area , acronym = 'mars' )
333+ draft = DocumentFactory (type_id = 'draft' , group = group , stream_id = stream_type , ad = ad , authors = PersonFactory .create_batch (1 ))
335334 draft .set_state (State .objects .get (type_id = 'draft-stream-ietf' ,slug = 'wg-doc' ))
335+
336+ # pretend IANA reviewed it
337+ draft .set_state (State .objects .get (used = True , type = "draft-iana-review" , slug = "not-ok" ))
338+
339+ # pretend it was approved to check that we notify the RFC Editor
340+ e = DocEvent (type = "iesg_approved" , doc = draft , rev = draft .rev )
341+ e .time = draft .time
342+ e .by = Person .objects .get (name = "(System)" )
343+ e .desc = "The IESG approved the document"
344+ e .save ()
345+
346+ # make a discuss to see if the AD gets an email
347+ ad = Person .objects .get (user__username = "ad" )
348+ ballot = create_ballot_if_not_open (None , draft , ad , 'approve' )
349+ ballot_position = BallotPositionDocEvent ()
350+ ballot_position .ballot = ballot
351+ ballot_position .pos_id = "discuss"
352+ ballot_position .type = "changed_ballot_position"
353+ ballot_position .doc = draft
354+ ballot_position .rev = draft .rev
355+ ballot_position .ad = ballot_position .by = Person .objects .get (user__username = "ad2" )
356+ ballot_position .save ()
357+
358+ elif stream_type == 'irtf' :
359+ group = GroupFactory (type_id = 'rg' , parent = Group .objects .get (acronym = 'irtf' ), acronym = 'mars' )
360+ draft = DocumentFactory (type_id = 'draft' , group = group , stream_id = 'irtf' , authors = PersonFactory .create_batch (1 ))
361+
362+ else :
363+ draft = IndividualDraftFactory (stream_id = stream_type , authors = PersonFactory .create_batch (1 ))
336364
337365 prev_author = draft .documentauthor_set .all ()[0 ]
338366 if change_authors :
339367 # Make it such that one of the previous authors has an invalid email address
340368 bogus_person , bogus_email = ensure_person_email_info_exists (u'Bogus Person' , None , draft .name )
341369 DocumentAuthor .objects .create (document = draft , person = bogus_person , email = bogus_email , order = draft .documentauthor_set .latest ('order' ).order + 1 )
342370
343- # pretend IANA reviewed it
344- draft .set_state (State .objects .get (used = True , type = "draft-iana-review" , slug = "not-ok" ))
345-
346- # pretend it was approved to check that we notify the RFC Editor
347- e = DocEvent (type = "iesg_approved" , doc = draft , rev = draft .rev )
348- e .time = draft .time
349- e .by = Person .objects .get (name = "(System)" )
350- e .desc = "The IESG approved the document"
351- e .save ()
352-
353- # make a discuss to see if the AD gets an email
354- # TODO : this should only happen if the document stream is IETF
355- ad = Person .objects .get (user__username = "ad" )
356- ballot = create_ballot_if_not_open (None , draft , ad , 'approve' )
357- ballot_position = BallotPositionDocEvent ()
358- ballot_position .ballot = ballot
359- ballot_position .pos_id = "discuss"
360- ballot_position .type = "changed_ballot_position"
361- ballot_position .doc = draft
362- ballot_position .rev = draft .rev
363- ballot_position .ad = ballot_position .by = Person .objects .get (user__username = "ad2" )
364- ballot_position .save ()
365-
366371 # Set the revision needed tag
367372 draft .tags .add ("need-rev" )
368373
@@ -375,6 +380,8 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
375380 with open (os .path .join (self .repository_dir , "%s-%s.txt" % (name , old_rev )), 'w' ) as f :
376381 f .write ("a" * 2000 )
377382
383+ old_docevents = list (draft .docevent_set .all ())
384+
378385 status_url , author = self .do_submission (name , rev , group , formats , author = prev_author .person )
379386
380387 # supply submitter info, then previous authors get a confirmation email
@@ -405,9 +412,8 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
405412 self .assertTrue ("aread@" in confirm_email ["To" ].lower ())
406413 else :
407414 pass
408- if stream_type not in 'ietf' :
409- if stream_type == 'ise' :
410- self .assertTrue ("rfc-ise@" in confirm_email ["To" ].lower ())
415+ if stream_type == 'ise' :
416+ self .assertTrue ("rfc-ise@" in confirm_email ["To" ].lower ())
411417 else :
412418 self .assertNotIn ("chairs have been copied" , unicode (confirm_email ))
413419 self .assertNotIn ("mars-chairs@" , confirm_email ["To" ].lower ())
@@ -424,8 +430,10 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
424430 r = self .client .post (confirm_url , {'action' :'confirm' })
425431 self .assertEqual (r .status_code , 302 )
426432
433+ new_docevents = draft .docevent_set .exclude (pk__in = [event .pk for event in old_docevents ])
434+
427435 # check we have document events
428- doc_events = draft . docevent_set .filter (type__in = ["new_submission" , "added_comment" ])
436+ doc_events = new_docevents .filter (type__in = ["new_submission" , "added_comment" ])
429437 edescs = '::' .join ([x .desc for x in doc_events ])
430438 self .assertTrue ('New version approved' in edescs )
431439 self .assertTrue ('Uploaded new revision' in edescs )
@@ -434,42 +442,33 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
434442 self .assertEqual (draft .rev , rev )
435443 self .assertEqual (draft .group .acronym , name .split ("-" )[2 ])
436444 #
437- docevents = list (draft . docevent_set . all () .order_by ("-time" , "-id" ))
445+ docevents = list (new_docevents .order_by ("-time" , "-id" ))
438446 # Latest events are first (this is the default, but we make it explicit)
439447 # Assert event content in chronological order:
440- self .assertEqual (docevents [5 ].type , "new_submission" )
441- self .assertIn ("Uploaded new revision" , docevents [5 ].desc )
442- self .assertEqual (docevents [5 ].by .name , "Submitter Name" )
443- self .assertGreater (docevents [5 ].id , docevents [6 ].id )
444- #
445- self .assertEqual (docevents [4 ].type , "new_submission" )
446- self .assertIn ("Request for posting confirmation" , docevents [4 ].desc )
447- self .assertEqual (docevents [4 ].by .name , "(System)" )
448- self .assertGreater (docevents [4 ].id , docevents [5 ].id )
449- #
450- self .assertEqual (docevents [3 ].type , "new_submission" )
451- self .assertIn ("New version approved" , docevents [3 ].desc )
452- self .assertEqual (docevents [3 ].by .name , "(System)" )
453- self .assertGreater (docevents [3 ].id , docevents [4 ].id )
454- #
455- self .assertEqual (docevents [2 ].type , "new_revision" )
456- self .assertIn ("New version available" , docevents [2 ].desc )
457- self .assertEqual (docevents [2 ].by .name , "Submitter Name" )
458- self .assertGreater (docevents [2 ].id , docevents [3 ].id )
459- #
460- self .assertEqual (docevents [1 ].type , "changed_state" )
461- self .assertIn ("IANA Review" , docevents [1 ].desc )
462- self .assertEqual (docevents [1 ].by .name , "(System)" )
463- self .assertGreater (docevents [1 ].id , docevents [2 ].id )
464- #
465- self .assertEqual (docevents [0 ].type , "changed_document" )
448+
449+ def inspect_docevents (docevents , event_delta , type , be_in_desc , by_name ):
450+ self .assertEqual (docevents [event_delta ].type , type )
451+ self .assertIn (be_in_desc , docevents [event_delta ].desc )
452+ self .assertEqual (docevents [event_delta ].by .name , by_name )
453+ if len (docevents ) > event_delta + 1 :
454+ self .assertGreater (docevents [event_delta ].id , docevents [event_delta + 1 ].id )
455+
466456 if draft .stream_id == 'ietf' :
467- self .assertIn ("AD Followup" , docevents [0 ].desc )
457+ inspect_docevents (docevents , 5 , "new_submission" , "Uploaded new revision" , "Submitter Name" )
458+ inspect_docevents (docevents , 4 , "new_submission" , "Request for posting confirmation" , "(System)" )
459+ inspect_docevents (docevents , 3 , "new_submission" , "New version approved" , "(System)" )
460+ inspect_docevents (docevents , 2 , "new_revision" , "New version available" , "Submitter Name" )
461+ inspect_docevents (docevents , 1 , "changed_state" , "IANA Review" , "(System)" )
462+ inspect_docevents (docevents , 0 , "changed_document" , "AD Followup" , "(System)" )
463+ elif draft .stream_id in ('ise' , 'irtf' , 'iab' ):
464+ inspect_docevents (docevents , 4 , "new_submission" , "Uploaded new revision" , "Submitter Name" )
465+ inspect_docevents (docevents , 3 , "new_submission" , "Request for posting confirmation" , "(System)" )
466+ inspect_docevents (docevents , 2 , "new_submission" , "New version approved" , "(System)" )
467+ inspect_docevents (docevents , 1 , "new_revision" , "New version available" , "Submitter Name" )
468+ inspect_docevents (docevents , 0 , "changed_document" , "tag cleared" , "(System)" )
468469 else :
469- self .assertIn ("tag cleared" , docevents [0 ].desc )
470- self .assertEqual (docevents [0 ].by .name , "(System)" )
471- self .assertGreater (docevents [0 ].id , docevents [1 ].id )
472- #
470+ pass
471+
473472 self .assertTrue (not os .path .exists (os .path .join (self .repository_dir , "%s-%s.txt" % (name , old_rev ))))
474473 self .assertTrue (os .path .exists (os .path .join (self .archive_dir , "%s-%s.txt" % (name , old_rev ))))
475474 self .assertTrue (not os .path .exists (os .path .join (self .staging_dir , u"%s-%s.txt" % (name , rev ))))
@@ -478,7 +477,7 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
478477 if stream_type == 'ietf' :
479478 self .assertEqual (draft .stream_id , "ietf" )
480479 self .assertEqual (draft .get_state_slug ("draft-stream-%s" % draft .stream_id ), "wg-doc" )
481- self .assertEqual (draft .get_state_slug ("draft-iana-review" ), "changed" )
480+ self .assertEqual (draft .get_state_slug ("draft-iana-review" ), "changed" )
482481 authors = draft .documentauthor_set .all ()
483482 self .assertEqual (len (authors ), 1 )
484483 self .assertIn (author , [ a .person for a in authors ])
@@ -489,13 +488,13 @@ def submit_existing(self, formats, change_authors=True, group_type='wg', stream_
489488 self .assertTrue ("i-d-announce@" in outbox [- 3 ]['To' ])
490489 self .assertTrue ("New Version Notification" in outbox [- 2 ]["Subject" ])
491490 self .assertTrue (name in unicode (outbox [- 2 ]))
492- self .assertTrue ("mars" in unicode (outbox [- 2 ]))
493- self .assertTrue (draft .ad .role_email ("ad" ).address in unicode (outbox [- 2 ]))
494- self .assertTrue (ballot_position .ad .role_email ("ad" ).address in unicode (outbox [- 2 ]))
491+ interesting_address = {'ietf' :'mars' , 'irtf' :'irtf-chair' , 'iab' :'iab-chair' , 'ise' :'rfc-ise' }[draft .stream_id ]
492+ self .assertTrue (interesting_address in unicode (outbox [- 2 ]))
493+ if draft .stream_id == 'ietf' :
494+ self .assertTrue (draft .ad .role_email ("ad" ).address in unicode (outbox [- 2 ]))
495+ self .assertTrue (ballot_position .ad .role_email ("ad" ).address in unicode (outbox [- 2 ]))
495496 self .assertTrue ("New Version Notification" in outbox [- 1 ]["Subject" ])
496497 self .assertTrue (name in unicode (outbox [- 1 ]))
497- self .assertTrue ("mars" in unicode (outbox [- 1 ]))
498- #
499498 r = self .client .get (urlreverse ('ietf.doc.views_search.recent_drafts' ))
500499 self .assertEqual (r .status_code , 200 )
501500 self .assertIn (draft .name , unicontent (r ))
@@ -515,7 +514,7 @@ def test_submit_existing_txt_preserve_authors(self):
515514 self .submit_existing (["txt" ], change_authors = False )
516515
517516 def test_submit_existing_rg (self ):
518- self .submit_existing (["txt" ],group_type = 'rg' )
517+ self .submit_existing (["txt" ],group_type = 'rg' , stream_type = 'irtf' )
519518
520519 def test_submit_existing_ag (self ):
521520 self .submit_existing (["txt" ],group_type = 'ag' )
@@ -524,7 +523,10 @@ def test_submit_existing_area(self):
524523 self .submit_existing (["txt" ],group_type = 'area' )
525524
526525 def test_submit_existing_ise (self ):
527- self .submit_existing (["txt" ],stream_type = 'ise' )
526+ self .submit_existing (["txt" ],stream_type = 'ise' , group_type = 'individ' )
527+
528+ def test_submit_existing_iab (self ):
529+ self .submit_existing (["txt" ],stream_type = 'iab' , group_type = 'individ' )
528530
529531 def submit_new_individual (self , formats ):
530532 # submit new -> supply submitter info -> confirm
0 commit comments