From 6c0c5a0aea77387ea4873bee27e8df88f867002b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 6 Jul 2014 17:29:23 +0100 Subject: Add conversion from document table to HTML table --- tests/conversion_tests.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') 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 @@ -170,6 +170,27 @@ def docx_tab_is_converted_to_tab_in_html(): assert_equal('\t', result.value) +@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 = ( + "" + + "" + + "" + + "

Top left

Top right

Bottom left

Bottom right

") + 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")) @@ -196,5 +217,9 @@ def can_define_custom_conversion_for_images(): assert_equal('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)]) -- cgit v1.2.3