aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-14 16:16:51 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-14 16:16:51 +0000
commit94638afbc228c9005e302ab6bc3d16c4e3e32b1d (patch)
treebbde2adf4a67f177711e7ddef2f9704473dd88c3 /tests
parent47c7a524e001bd0d9aef872b4a12c0b8efd0d6ff (diff)
Add conversion of paragraphs using styles
Diffstat (limited to 'tests')
-rw-r--r--tests/conversion_tests.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py
new file mode 100644
index 0000000..ab90eb0
--- /dev/null
+++ b/tests/conversion_tests.py
@@ -0,0 +1,37 @@
+from nose.tools import istest, assert_equal
+
+from mammoth import documents, style_reader
+from mammoth.conversion import convert_document_element_to_html
+
+
+@istest
+def plain_paragraph_is_converted_to_plain_paragraph():
+ result = convert_document_element_to_html(
+ documents.paragraph(children=[_run_with_text("Hello")])
+ )
+ assert_equal('<p>Hello</p>', result.value)
+
+
+@istest
+def empty_paragraphs_are_ignored():
+ result = convert_document_element_to_html(
+ documents.paragraph(children=[_run_with_text("")])
+ )
+ assert_equal('', result.value)
+
+
+@istest
+def paragraphs_are_converted_by_satisfying_matching_paths():
+ result = convert_document_element_to_html(
+ documents.paragraph(style_name="TipsParagraph", children=[
+ _run_with_text("Tip")
+ ]),
+ styles=[
+ style_reader.read_style("p.TipsParagraph => p.tip")
+ ]
+ )
+ assert_equal('<p class="tip">Tip</p>', result.value)
+
+
+def _run_with_text(text):
+ return documents.run(children=[documents.text(text)])