Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion ietf/utils/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2014-2020, All Rights Reserved
# Copyright The IETF Trust 2014-2025, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -741,6 +741,23 @@ def test_render_author_name(self):
"J. Q.",
)

@patch("ietf.utils.xmldraft.XMLDraft.__init__", return_value=None)
def test_get_title(self, mock_init):
xmldraft = XMLDraft("fake")
self.assertTrue(mock_init.called)
# Stub XML that does not have a front/title element
xmldraft.xmlroot = lxml.etree.XML(
"<rfc><front></front></rfc>" # no title
)
self.assertEqual(xmldraft.get_title(), "")

# Stub XML that has a front/title element
xmldraft.xmlroot = lxml.etree.XML(
"<rfc><front><title>This Is the Title</title></front></rfc>"
)
self.assertEqual(xmldraft.get_title(), "This Is the Title")


def test_capture_xml2rfc_output(self):
"""capture_xml2rfc_output reroutes and captures xml2rfc logs"""
orig_write_out = xml2rfc_log.write_out
Expand Down
5 changes: 3 additions & 2 deletions ietf/utils/xmldraft.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2022, All Rights Reserved
# Copyright The IETF Trust 2022-2025, All Rights Reserved
# -*- coding: utf-8 -*-
import datetime
import io
Expand Down Expand Up @@ -147,7 +147,8 @@ def parse_docname(xmlroot):
return revmatch.group('filename'), revmatch.group('rev')

def get_title(self):
return self.xmlroot.findtext('front/title').strip()
title_text = self.xmlroot.findtext('front/title')
return "" if title_text is None else title_text.strip()

@staticmethod
def parse_creation_date(date_elt):
Expand Down
Loading