From 04cae35fcaaffa42fea663865b6cb11c117d423b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 19 Mar 2014 10:16:42 +0000 Subject: Assert image file output when using CLI --- tests/cli_tests.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/cli_tests.py') diff --git a/tests/cli_tests.py b/tests/cli_tests.py index b23ae9a..c8f8ac9 100644 --- a/tests/cli_tests.py +++ b/tests/cli_tests.py @@ -1,4 +1,5 @@ import os +import base64 from nose.tools import istest, assert_equal import spur @@ -29,21 +30,28 @@ def html_is_written_to_file_if_output_file_is_set(): assert_equal("

Walking on imported air

", output_file.read()) +_image_base_64 = b"iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=" + @istest def inline_images_are_included_in_output_if_writing_to_single_file(): docx_path = test_path("tiny-picture.docx") result = _local.run(["mammoth", docx_path]) - assert_equal(b"""

""", result.output) + assert_equal(b"""

""", result.output) @istest def images_are_written_to_separate_files_if_output_dir_is_set(): with tempman.create_temp_dir() as temp_dir: output_path = os.path.join(temp_dir.path, "tiny-picture.html") + image_path = os.path.join(temp_dir.path, "1.png") + docx_path = test_path("tiny-picture.docx") result = _local.run(["mammoth", docx_path, "--output-dir", temp_dir.path]) assert_equal(b"", result.stderr_output) assert_equal(b"", result.output) with open(output_path) as output_file: assert_equal("""

""", output_file.read()) + + with open(image_path, "rb") as image_file: + assert_equal(_image_base_64, base64.b64encode(image_file.read())) -- cgit v1.2.3