From 83e897fe523a84630ec7bfd9805a887128897082 Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Tue, 1 Oct 2024 09:41:43 +1300 Subject: [PATCH] fix(text): Capitalize "type" in non-ASCII artwork message (#1170) * chore: Run yestests pre-changes * fix(text): Capitalize "type" in non-ASCII artwork message Fixes #1169 * chore: Run yestests post-changes --- test.py | 47 ++++++++++++++++++++++++++++-- tests/valid/draft-v3-features.text | 10 +++---- tests/valid/elements.bom.text | 4 +-- tests/valid/elements.pages.text | 4 +-- tests/valid/elements.text | 4 +-- tests/valid/elements.wip.text | 4 +-- tests/valid/indexes.pages.text | 12 ++++---- tests/valid/indexes.prepped.xml | 6 ++-- tests/valid/indexes.text | 6 ++-- tests/valid/indexes.v3.html | 8 ++--- tests/valid/manpage.txt | 2 +- tests/valid/sourcecode.pages.text | 14 ++++----- tests/valid/sourcecode.prepped.xml | 6 ++-- tests/valid/sourcecode.text | 6 ++-- tests/valid/sourcecode.v3.html | 8 ++--- xml2rfc/writers/text.py | 3 +- 16 files changed, 94 insertions(+), 50 deletions(-) diff --git a/test.py b/test.py index b525ccc8..3c2dd5d5 100644 --- a/test.py +++ b/test.py @@ -712,7 +712,7 @@ def test_render_artwork_svg_only(self): self.writer.rfcnumber = 1234 lines = self.writer.render_artwork(artwork, width=60) text = ''.join(line.text for line in lines) - self.assertIn("Artwork only available as svg", text) + self.assertIn("Artwork only available as SVG", text) self.assertIn(default_options.rfc_html_archive_url, text) self.assertIn('rfc1234.html', text) @@ -720,10 +720,53 @@ def test_render_artwork_svg_only(self): self.writer.options.rfc = None lines = self.writer.render_artwork(artwork, width=60) text = ' '.join(line.text for line in lines) - self.assertIn("Artwork only available as svg", text) + self.assertIn("Artwork only available as SVG", text) self.assertIn(default_options.id_html_archive_url, text) self.assertIn(".html", text) + def test_render_artwork_binary_art_only(self): + artwork_str = '' + artwork = lxml.etree.fromstring(artwork_str) + + # for RFC + self.writer.root = lxml.etree.fromstring(f'') + self.writer.options.rfc = True + self.writer.rfcnumber = 1234 + lines = self.writer.render_artwork(artwork, width=60) + text = ''.join(line.text for line in lines) + self.assertIn("Artwork only available as BINARY-ART", text) + self.assertIn(default_options.rfc_html_archive_url, text) + self.assertIn('rfc1234.html', text) + + # for Draft + self.writer.options.rfc = None + lines = self.writer.render_artwork(artwork, width=60) + text = ' '.join(line.text for line in lines) + self.assertIn("Artwork only available as BINARY-ART", text) + self.assertIn(default_options.id_html_archive_url, text) + self.assertIn(".html", text) + + def test_render_artwork_non_ascii_unknown(self): + artwork_str = '' + artwork = lxml.etree.fromstring(artwork_str) + + # for RFC + self.writer.root = lxml.etree.fromstring(f'') + self.writer.options.rfc = True + self.writer.rfcnumber = 1234 + lines = self.writer.render_artwork(artwork, width=60) + text = ''.join(line.text for line in lines) + self.assertIn("Artwork only available as (unknown type)", text) + self.assertIn(default_options.rfc_html_archive_url, text) + self.assertIn('rfc1234.html', text) + + # for Draft + self.writer.options.rfc = None + lines = self.writer.render_artwork(artwork, width=60) + text = ' '.join(line.text for line in lines) + self.assertIn("Artwork only available as (unknown type)", text) + self.assertIn(default_options.id_html_archive_url, text) + self.assertIn(".html", text) class BaseV3WriterTest(unittest.TestCase): diff --git a/tests/valid/draft-v3-features.text b/tests/valid/draft-v3-features.text index cab29a6f..62e42ff3 100644 --- a/tests/valid/draft-v3-features.text +++ b/tests/valid/draft-v3-features.text @@ -519,7 +519,7 @@ Table of Contents Text before... - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/draft-v3-features.html) Text after... @@ -528,7 +528,7 @@ Table of Contents Text before... - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/draft-v3-features.html) Text after... @@ -537,7 +537,7 @@ Table of Contents Text before... - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/draft-v3-features.html) Text after... @@ -546,14 +546,14 @@ Table of Contents Text before... - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/draft-v3-features.html) Text after... 8.5. included (type svg) - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/draft-v3-features.html) +--------------------+ | Included from file | diff --git a/tests/valid/elements.bom.text b/tests/valid/elements.bom.text index aa9f5d78..d658816e 100644 --- a/tests/valid/elements.bom.text +++ b/tests/valid/elements.bom.text @@ -355,12 +355,12 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 * Artset include with - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) * Unicode SVG rendering test - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) 4. Ordered list with sub-elements diff --git a/tests/valid/elements.pages.text b/tests/valid/elements.pages.text index 74cb129a..371752ff 100644 --- a/tests/valid/elements.pages.text +++ b/tests/valid/elements.pages.text @@ -355,12 +355,12 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 * Artset include with - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) * Unicode SVG rendering test - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) 4. Ordered list with sub-elements diff --git a/tests/valid/elements.text b/tests/valid/elements.text index 52aa5c46..7c9c2099 100644 --- a/tests/valid/elements.text +++ b/tests/valid/elements.text @@ -302,12 +302,12 @@ Table of Contents * Artset include with - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) * Unicode SVG rendering test - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) 4. Ordered list with sub-elements diff --git a/tests/valid/elements.wip.text b/tests/valid/elements.wip.text index 843255c2..9261689e 100644 --- a/tests/valid/elements.wip.text +++ b/tests/valid/elements.wip.text @@ -355,12 +355,12 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 * Artset include with - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) * Unicode SVG rendering test - (Artwork only available as svg: see + (Artwork only available as SVG: see https://www.ietf.org/archive/id/elements-00.html) 4. Ordered list with sub-elements diff --git a/tests/valid/indexes.pages.text b/tests/valid/indexes.pages.text index 989b67bb..5daab1e6 100644 --- a/tests/valid/indexes.pages.text +++ b/tests/valid/indexes.pages.text @@ -3,9 +3,9 @@ Network Working Group H. Person, Ed. -Internet-Draft September 20, 2024 +Internet-Draft September 26, 2024 Intended status: Experimental -Expires: March 24, 2025 +Expires: March 30, 2025 xml2rfc index tests @@ -26,7 +26,7 @@ Status of This Memo time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on March 24, 2025. + This Internet-Draft will expire on March 30, 2025. Copyright Notice @@ -53,7 +53,7 @@ Table of Contents -Person Expires March 24, 2025 [Page 1] +Person Expires March 30, 2025 [Page 1] Internet-Draft xml2rfc index tests September 2024 @@ -109,7 +109,7 @@ Index -Person Expires March 24, 2025 [Page 2] +Person Expires March 30, 2025 [Page 2] Internet-Draft xml2rfc index tests September 2024 @@ -165,4 +165,4 @@ Author's Address -Person Expires March 24, 2025 [Page 3] +Person Expires March 30, 2025 [Page 3] diff --git a/tests/valid/indexes.prepped.xml b/tests/valid/indexes.prepped.xml index e617b237..913b1e83 100644 --- a/tests/valid/indexes.prepped.xml +++ b/tests/valid/indexes.prepped.xml @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@ - +
Status of This Memo @@ -41,7 +41,7 @@ material or to cite them other than as "work in progress." - This Internet-Draft will expire on 24 March 2025. + This Internet-Draft will expire on 30 March 2025.
diff --git a/tests/valid/indexes.text b/tests/valid/indexes.text index 1c63e764..8bef89ec 100644 --- a/tests/valid/indexes.text +++ b/tests/valid/indexes.text @@ -3,9 +3,9 @@ Network Working Group H. Person, Ed. -Internet-Draft September 20, 2024 +Internet-Draft September 26, 2024 Intended status: Experimental -Expires: March 24, 2025 +Expires: March 30, 2025 xml2rfc index tests @@ -26,7 +26,7 @@ Status of This Memo time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on March 24, 2025. + This Internet-Draft will expire on March 30, 2025. Copyright Notice diff --git a/tests/valid/indexes.v3.html b/tests/valid/indexes.v3.html index b004e0a8..36a10245 100644 --- a/tests/valid/indexes.v3.html +++ b/tests/valid/indexes.v3.html @@ -23,7 +23,7 @@ Person -Expires March 24, 2025 +Expires March 30, 2025 [Page] @@ -36,12 +36,12 @@
indexes-00
Published:
- +
Intended Status:
Experimental
Expires:
-
+
Author:
@@ -71,7 +71,7 @@

time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

- This Internet-Draft will expire on March 24, 2025.

+ This Internet-Draft will expire on March 30, 2025.