diff --git a/ietf/bin/rfc-editor-index-updates b/ietf/bin/rfc-editor-index-updates index da9f85f9b..c3e8f1f46 100755 --- a/ietf/bin/rfc-editor-index-updates +++ b/ietf/bin/rfc-editor-index-updates @@ -79,12 +79,12 @@ if len(errata_data) < ietf.sync.rfceditor.MIN_ERRATA_RESULTS: sys.exit(1) new_rfcs = [] -for changes, doc, rfc_published in ietf.sync.rfceditor.update_docs_from_rfc_index(index_data, errata_data, skip_older_than_date=skip_date): +for rfc_number, changes, doc, rfc_published in ietf.sync.rfceditor.update_docs_from_rfc_index(index_data, errata_data, skip_older_than_date=skip_date): if rfc_published: new_rfcs.append(doc) for c in changes: - log("RFC%s, %s: %s" % (doc.rfc_number, doc.name, c)) + log("RFC%s, %s: %s" % (rfc_number, doc.name, c)) sys.exit(0) diff --git a/ietf/sync/rfceditor.py b/ietf/sync/rfceditor.py index 7a476e136..ce654101c 100644 --- a/ietf/sync/rfceditor.py +++ b/ietf/sync/rfceditor.py @@ -336,10 +336,11 @@ def parse_index(response): def update_docs_from_rfc_index( index_data, errata_data, skip_older_than_date=None -) -> Iterator[tuple[list[str], Document, bool]]: +) -> Iterator[tuple[int, list[str], Document, bool]]: """Given parsed data from the RFC Editor index, update the documents in the database - Yields a list of change descriptions for each document, if any. + Returns an iterator that yields (rfc_number, change_list, doc, rfc_published) for the + RFC document and, if applicable, the I-D that it came from. The skip_older_than_date is a bare date, not a datetime. """ @@ -553,7 +554,7 @@ def update_docs_from_rfc_index( ) ) draft.save_with_history(draft_events) - yield draft_changes, draft, False # yield changes to the draft + yield rfc_number, draft_changes, draft, False # yield changes to the draft # check attributes verbed = "set" if created_rfc else "changed" @@ -757,7 +758,7 @@ def update_docs_from_rfc_index( ) ) doc.save_with_history(rfc_events) - yield rfc_changes, doc, rfc_published # yield changes to the RFC + yield rfc_number, rfc_changes, doc, rfc_published # yield changes to the RFC if first_sync_creating_subseries: # First - create the known subseries documents that have ghosted. diff --git a/ietf/sync/tests.py b/ietf/sync/tests.py index 49306c47c..db6c1fba1 100644 --- a/ietf/sync/tests.py +++ b/ietf/sync/tests.py @@ -350,8 +350,16 @@ class RFCSyncTests(TestCase): changes = [] with mock.patch("ietf.sync.rfceditor.log") as mock_log: - for _, d, rfc_published in rfceditor.update_docs_from_rfc_index(data, errata, today - datetime.timedelta(days=30)): + for rfc_number, _, d, rfc_published in rfceditor.update_docs_from_rfc_index(data, errata, today - datetime.timedelta(days=30)): changes.append({"doc_pk": d.pk, "rfc_published": rfc_published}) # we ignore the actual change list + self.assertEqual(rfc_number, 1234) + if rfc_published: + self.assertEqual(d.type_id, "rfc") + self.assertEqual(d.rfc_number, rfc_number) + else: + self.assertEqual(d.type_id, "draft") + self.assertIsNone(d.rfc_number) + self.assertFalse(mock_log.called, "No log messages expected") draft_doc = Document.objects.get(name=draft_doc.name)