Test html output
This commit is contained in:
parent
16b6002205
commit
c6100c04c6
3 changed files with 28 additions and 2 deletions
|
@ -15,7 +15,7 @@ def build(config):
|
||||||
logger.debug("Starting Build...")
|
logger.debug("Starting Build...")
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
data = read_files(os.path.abspath(config['input']))
|
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)
|
parsed_template = parse_template(doc, config)
|
||||||
if 'html' in config['output_formats']:
|
if 'html' in config['output_formats']:
|
||||||
output_html(parsed_template, os.path.abspath(config['output_dir']))
|
output_html(parsed_template, os.path.abspath(config['output_dir']))
|
||||||
|
|
|
@ -12,7 +12,7 @@ def output_html(html, out_dir):
|
||||||
f.write(html)
|
f.write(html)
|
||||||
|
|
||||||
|
|
||||||
def build_document(files_content, bibliography, context):
|
def build_document(files_content, bibliography):
|
||||||
args = [
|
args = [
|
||||||
'-s',
|
'-s',
|
||||||
]
|
]
|
||||||
|
|
26
tests/test_pandoc.py
Normal file
26
tests/test_pandoc.py
Normal file
|
@ -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')
|
||||||
|
|
Reference in a new issue