@@ -381,17 +381,15 @@ def test_rfc_index(self):
381381 changed = list (rfceditor .update_docs_from_rfc_index (data , errata , today - datetime .timedelta (days = 30 )))
382382 self .assertEqual (len (changed ), 0 )
383383
384-
385- def test_rfc_queue (self ):
386- draft = WgDraftFactory (states = [('draft-iesg' ,'ann' )])
387-
384+ def _generate_rfc_queue_xml (self , draft , state , auth48_url = None ):
385+ """Generate an RFC queue xml string for a draft"""
388386 t = '''<rfc-editor-queue xmlns="http://www.rfc-editor.org/rfc-editor-queue">
389387<section name="IETF STREAM: WORKING GROUP STANDARDS TRACK">
390388<entry xml:id="%(name)s">
391389<draft>%(name)s-%(rev)s.txt</draft>
392390<date-received>2010-09-08</date-received>
393- <state>EDIT*R*A(1G) </state>
394- <auth48-url>http://www.rfc-editor.org/auth48/rfc1234 </auth48-url>
391+ <state>%(state)s </state>
392+ <auth48-url>%(auth48_url)s </auth48-url>
395393<normRef>
396394<ref-name>%(ref)s</ref-name>
397395<ref-state>IN-QUEUE</ref-state>
@@ -408,26 +406,24 @@ def test_rfc_queue(self):
408406 rev = draft .rev ,
409407 title = draft .title ,
410408 group = draft .group .name ,
411- ref = "draft-ietf-test" )
409+ ref = "draft-ietf-test" ,
410+ state = state ,
411+ auth48_url = (auth48_url or '' ))
412+ t = t .replace ('<auth48-url></auth48-url>\n ' , '' ) # strip empty auth48-url tags
413+ return t
414+
415+ def test_rfc_queue (self ):
416+ draft = WgDraftFactory (states = [('draft-iesg' ,'ann' )])
417+ expected_auth48_url = "http://www.rfc-editor.org/auth48/rfc1234"
418+ t = self ._generate_rfc_queue_xml (draft ,
419+ state = 'EDIT*R*A(1G)' ,
420+ auth48_url = expected_auth48_url )
412421
413422 drafts , warnings = rfceditor .parse_queue (io .StringIO (t ))
423+ # rfceditor.parse_queue() is tested independently; just sanity check here
414424 self .assertEqual (len (drafts ), 1 )
415425 self .assertEqual (len (warnings ), 0 )
416426
417- # Test with TI state introduced 11 Sep 2019
418- t = t .replace ("<state>EDIT*R*A(1G)</state>" , "<state>TI</state>" )
419- __ , warnings = rfceditor .parse_queue (io .StringIO (t ))
420- self .assertEqual (len (warnings ), 0 )
421-
422- draft_name , date_received , state , tags , missref_generation , stream , auth48 , cluster , refs = drafts [0 ]
423-
424- # currently, we only check what we actually use
425- self .assertEqual (draft_name , draft .name )
426- self .assertEqual (state , "EDIT" )
427- self .assertEqual (set (tags ), set (["iana" , "ref" ]))
428- self .assertEqual (auth48 , "http://www.rfc-editor.org/auth48/rfc1234" )
429-
430-
431427 mailbox_before = len (outbox )
432428
433429 changed , warnings = rfceditor .update_drafts_from_queue (drafts )
@@ -450,6 +446,83 @@ def test_rfc_queue(self):
450446 self .assertEqual (len (changed ), 0 )
451447 self .assertEqual (len (warnings ), 0 )
452448
449+ def test_rfceditor_parse_queue (self ):
450+ """Test that rfceditor.parse_queue() behaves as expected.
451+
452+ Currently does a limited test - old comment was
453+ "currently, we only check what we actually use".
454+ """
455+ draft = WgDraftFactory (states = [('draft-iesg' ,'ann' )])
456+ t = self ._generate_rfc_queue_xml (draft ,
457+ state = 'EDIT*R*A(1G)' ,
458+ auth48_url = "http://www.rfc-editor.org/auth48/rfc1234" )
459+
460+ drafts , warnings = rfceditor .parse_queue (io .StringIO (t ))
461+ self .assertEqual (len (drafts ), 1 )
462+ self .assertEqual (len (warnings ), 0 )
463+
464+ draft_name , date_received , state , tags , missref_generation , stream , auth48 , cluster , refs = drafts [0 ]
465+ self .assertEqual (draft_name , draft .name )
466+ self .assertEqual (state , "EDIT" )
467+ self .assertEqual (set (tags ), set (["iana" , "ref" ]))
468+ self .assertEqual (auth48 , "http://www.rfc-editor.org/auth48/rfc1234" )
469+
470+ def test_rfceditor_parse_queue_TI_state (self ):
471+ # Test with TI state introduced 11 Sep 2019
472+ draft = WgDraftFactory (states = [('draft-iesg' ,'ann' )])
473+ t = self ._generate_rfc_queue_xml (draft ,
474+ state = 'TI' ,
475+ auth48_url = "http://www.rfc-editor.org/auth48/rfc1234" )
476+ __ , warnings = rfceditor .parse_queue (io .StringIO (t ))
477+ self .assertEqual (len (warnings ), 0 )
478+
479+ def _generate_rfceditor_update (self , draft , state , tags = None , auth48_url = None ):
480+ """Helper to generate fake output from rfceditor.parse_queue()"""
481+ return [[
482+ draft .name , # draft_name
483+ '2020-06-03' , # date_received
484+ state ,
485+ tags or [],
486+ '1' , # missref_generation
487+ 'ietf' , # stream
488+ auth48_url or '' ,
489+ '' , # cluster
490+ ['draft-ietf-test' ], # refs
491+ ]]
492+
493+ def test_update_draft_auth48_url (self ):
494+ """Test that auth48 URLs are handled correctly."""
495+ draft = WgDraftFactory (states = [('draft-iesg' ,'ann' )])
496+
497+ # Step 1 setup: update to a state with no auth48 URL
498+ changed , warnings = rfceditor .update_drafts_from_queue (
499+ self ._generate_rfceditor_update (draft , state = 'EDIT' )
500+ )
501+ self .assertEqual (len (changed ), 1 )
502+ self .assertEqual (len (warnings ), 0 )
503+ auth48_docurl = draft .documenturl_set .filter (tag_id = 'auth48' ).first ()
504+ self .assertIsNone (auth48_docurl )
505+
506+ # Step 2: update to auth48 state with auth48 URL
507+ changed , warnings = rfceditor .update_drafts_from_queue (
508+ self ._generate_rfceditor_update (draft , state = 'AUTH48' , auth48_url = 'http://www.rfc-editor.org/rfc1234' )
509+ )
510+ self .assertEqual (len (changed ), 1 )
511+ self .assertEqual (len (warnings ), 0 )
512+ auth48_docurl = draft .documenturl_set .filter (tag_id = 'auth48' ).first ()
513+ self .assertIsNotNone (auth48_docurl )
514+ self .assertEqual (auth48_docurl .url , 'http://www.rfc-editor.org/rfc1234' )
515+
516+ # Step 3: update to auth48-done state without auth48 URL
517+ changed , warnings = rfceditor .update_drafts_from_queue (
518+ self ._generate_rfceditor_update (draft , state = 'AUTH48-DONE' )
519+ )
520+ self .assertEqual (len (changed ), 1 )
521+ self .assertEqual (len (warnings ), 0 )
522+ auth48_docurl = draft .documenturl_set .filter (tag_id = 'auth48' ).first ()
523+ self .assertIsNone (auth48_docurl )
524+
525+
453526class DiscrepanciesTests (TestCase ):
454527 def test_discrepancies (self ):
455528
0 commit comments