aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-06-08 22:25:35 +0100
committerMichael Williamson <mike@zwobble.org>2014-06-08 22:25:35 +0100
commitf37fce68a77630a199737959e9d235d0a1263662 (patch)
tree3a491f30099c8a548d6437b09e04ada4f24f28b8 /tests
parent6358a5201b97067e86cd06dff634bcefc6acb856 (diff)
Read style name for paragraphs out of source document
Diffstat (limited to 'tests')
-rw-r--r--tests/docx/document_xml_tests.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py
index e63cd60..e8757f5 100644
--- a/tests/docx/document_xml_tests.py
+++ b/tests/docx/document_xml_tests.py
@@ -8,6 +8,7 @@ from mammoth.docx.xmlparser import element as xml_element, text as xml_text
from mammoth.docx.document_xml import read_document_xml_element
from mammoth.docx.numbering_xml import Numbering
from mammoth.docx.relationships_xml import Relationships, Relationship
+from mammoth.docx.styles_xml import Styles, Style
@istest
@@ -51,10 +52,24 @@ class ReadXmlElementTests(object):
style_xml = xml_element("w:pStyle", {"w:val": "Heading1"})
properties_xml = xml_element("w:pPr", {}, [style_xml])
paragraph_xml = xml_element("w:p", {}, [properties_xml])
- paragraph = _read_and_get_document_xml_element(paragraph_xml)
+
+ styles = Styles({"Heading1": Style(style_id="Heading1", name="Heading 1")}, {})
+
+ paragraph = _read_and_get_document_xml_element(paragraph_xml, styles=styles)
assert_equal("Heading1", paragraph.style_id)
@istest
+ def paragraph_has_style_name_read_from_paragraph_properties_and_styles(self):
+ style_xml = xml_element("w:pStyle", {"w:val": "Heading1"})
+ properties_xml = xml_element("w:pPr", {}, [style_xml])
+ paragraph_xml = xml_element("w:p", {}, [properties_xml])
+
+ styles = Styles({"Heading1": Style(style_id="Heading1", name="Heading 1")}, {})
+
+ paragraph = _read_and_get_document_xml_element(paragraph_xml, styles=styles)
+ assert_equal("Heading 1", paragraph.style_name)
+
+ @istest
def paragraph_has_no_numbering_if_it_has_no_numbering_properties(self):
element = xml_element("w:p")
assert_equal(None, _read_and_get_document_xml_element(element).numbering)