From c6100c04c6e4cf2a79908308feb9826d51a1a5cf Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 28 May 2017 12:33:34 +0100 Subject: [PATCH] Test html output --- md_pdf/build/__init__.py | 2 +- md_pdf/build/pandoc.py | 2 +- tests/test_pandoc.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/test_pandoc.py diff --git a/md_pdf/build/__init__.py b/md_pdf/build/__init__.py index 27075f1..177216b 100644 --- a/md_pdf/build/__init__.py +++ b/md_pdf/build/__init__.py @@ -15,7 +15,7 @@ def build(config): logger.debug("Starting Build...") start_time = time.time() data = read_files(os.path.abspath(config['input'])) - doc = build_document(data, config.get('bibliography'), config.get('context')) + doc = build_document(data, config.get('bibliography')) parsed_template = parse_template(doc, config) if 'html' in config['output_formats']: output_html(parsed_template, os.path.abspath(config['output_dir'])) diff --git a/md_pdf/build/pandoc.py b/md_pdf/build/pandoc.py index 7bd86a2..1c7ab2d 100644 --- a/md_pdf/build/pandoc.py +++ b/md_pdf/build/pandoc.py @@ -12,7 +12,7 @@ def output_html(html, out_dir): f.write(html) -def build_document(files_content, bibliography, context): +def build_document(files_content, bibliography): args = [ '-s', ] diff --git a/tests/test_pandoc.py b/tests/test_pandoc.py new file mode 100644 index 0000000..e29e281 --- /dev/null +++ b/tests/test_pandoc.py @@ -0,0 +1,26 @@ +from tests import BaseTestCase +from md_pdf.build.pandoc import output_html, build_document +from md_pdf.utils import remove_dir +import os + +class OutputHTMLTestCase(BaseTestCase): + output_dir = 'test-output' + + def setUp(self): + super().setUp() + os.makedirs(self.output_dir) + + def tearDown(self): + super().tearDown() + remove_dir(self.output_dir) + + def test_outputs_file(self): + self.assertFalse(os.path.isfile(os.path.join(self.output_dir, 'output.html'))) + output_html('test', self.output_dir) + self.assertTrue(os.path.isfile(os.path.join(self.output_dir, 'output.html'))) + + def test_outputs_correct_data(self): + output_html('test', self.output_dir) + with open(os.path.join(self.output_dir, 'output.html')) as f: + self.assertEqual(f.read(), 'test') +