aboutsummaryrefslogtreecommitdiff
path: root/tests/conversion_tests.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-07-06 17:29:23 +0100
committerMichael Williamson <mike@zwobble.org>2014-07-06 17:29:23 +0100
commit6c0c5a0aea77387ea4873bee27e8df88f867002b (patch)
treea960b20643ede28e7c38556c8fc8bd265398a704 /tests/conversion_tests.py
parent9bfd191c00cf0d6f96eaf4e452cecadab711239e (diff)
Add conversion from document table to HTML table
Diffstat (limited to 'tests/conversion_tests.py')
-rw-r--r--tests/conversion_tests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py
index acac53b..3c5ff88 100644
--- a/tests/conversion_tests.py
+++ b/tests/conversion_tests.py
@@ -171,6 +171,27 @@ def docx_tab_is_converted_to_tab_in_html():
@istest
+def docx_table_is_converted_to_table_in_html():
+ table = documents.table([
+ documents.table_row([
+ documents.table_cell([_paragraph_with_text("Top left")]),
+ documents.table_cell([_paragraph_with_text("Top right")]),
+ ]),
+ documents.table_row([
+ documents.table_cell([_paragraph_with_text("Bottom left")]),
+ documents.table_cell([_paragraph_with_text("Bottom right")]),
+ ]),
+ ])
+ result = convert_document_element_to_html(table)
+ expected_html = (
+ "<table>" +
+ "<tr><td><p>Top left</p></td><td><p>Top right</p></td></tr>" +
+ "<tr><td><p>Bottom left</p></td><td><p>Bottom right</p></td></tr>" +
+ "</table>")
+ assert_equal(expected_html, result.value)
+
+
+@istest
def images_are_converted_to_img_tags_with_data_uri():
image = documents.image(alt_text=None, content_type="image/png", open=lambda: io.BytesIO(b"abc"))
result = convert_document_element_to_html(image)
@@ -196,5 +217,9 @@ def can_define_custom_conversion_for_images():
assert_equal('<img alt="abc" />', result.value)
+def _paragraph_with_text(text):
+ return documents.paragraph(children=[_run_with_text(text)])
+
+
def _run_with_text(text):
return documents.run(children=[documents.text(text)])