From f2db2bcf40c2c497a33b1f087b67111c3351a406 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Jul 2016 12:24:07 +0100 Subject: Read optional attributes of comments --- tests/docx/comments_xml_tests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/docx/comments_xml_tests.py b/tests/docx/comments_xml_tests.py index 5025a21..4963fe0 100644 --- a/tests/docx/comments_xml_tests.py +++ b/tests/docx/comments_xml_tests.py @@ -25,3 +25,23 @@ def when_optional_attributes_of_comment_are_missing_then_they_are_as_none(): comment, = comments.value assert_equal(None, comment.author_name) assert_equal(None, comment.author_initials) + + +@istest +def when_optional_attributes_of_comment_are_blank_then_they_are_as_none(): + comments = create_comments_reader(body_xml.reader())(xml_element("w:comments", {}, [ + xml_element("w:comment", {"w:id": "1", "w:author": " ", "w:initials": " "}, []), + ])) + comment, = comments.value + assert_equal(None, comment.author_name) + assert_equal(None, comment.author_initials) + + +@istest +def when_optional_attributes_of_comment_are_not_blank_then_they_are_read(): + comments = create_comments_reader(body_xml.reader())(xml_element("w:comments", {}, [ + xml_element("w:comment", {"w:id": "1", "w:author": "The Piemaker", "w:initials": "TP"}, []), + ])) + comment, = comments.value + assert_equal("The Piemaker", comment.author_name) + assert_equal("TP", comment.author_initials) -- cgit v1.2.3