From ac8a3c933a70c2d9aa179216f9ccfd2373c39c1b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 21 Jan 2015 17:44:59 +0000 Subject: Rename modules from footnotes to notes --- tests/docx/notes_xml_tests.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/docx/notes_xml_tests.py (limited to 'tests/docx/notes_xml_tests.py') diff --git a/tests/docx/notes_xml_tests.py b/tests/docx/notes_xml_tests.py new file mode 100644 index 0000000..90de8f8 --- /dev/null +++ b/tests/docx/notes_xml_tests.py @@ -0,0 +1,34 @@ +from nose.tools import istest, assert_equal + +from mammoth.docx.xmlparser import element as xml_element +from mammoth.docx.notes_xml import read_footnotes_xml_element + + +@istest +def id_and_body_of_footnote_are_read(): + footnote_body = [xml_element("w:p")] + footnotes = read_footnotes_xml_element(xml_element("w:footnotes", {}, [ + xml_element("w:footnote", {"w:id": "1"}, footnote_body), + ])) + assert_equal(1, len(footnotes)) + assert footnote_body is footnotes[0].body + assert_equal("1", footnotes[0].id) + + +@istest +def continuation_separator_is_ignored(): + _assert_footnote_type_is_ignored("continuationSeparator") + + +@istest +def separator_is_ignored(): + _assert_footnote_type_is_ignored("separator") + + +def _assert_footnote_type_is_ignored(footnote_type): + footnote_body = [xml_element("w:p")] + footnotes = read_footnotes_xml_element(xml_element("w:footnotes", {}, [ + xml_element("w:footnote", {"w:id": "1", "w:type": footnote_type}, footnote_body), + ])) + assert_equal(0, len(footnotes)) + -- cgit v1.2.3