Commit 2b7d398a by dorp

finished testing latex engine

parent 8cf69d6f
Presenting: \VAR{selected_analysis}
render_test.tex
\ No newline at end of file
render_test.tex
\ No newline at end of file
from pathlib import Path
import pytest
from pdf_generator.tex_generation.template_engine import (
byte_number_filter, convert_base64_to_png_filter, nice_number_filter, nice_unix_time, split_hash, split_output_lines
Engine, byte_number_filter, convert_base64_to_png_filter, filter_chars_in_list, filter_latex_special_chars,
nice_number_filter, nice_unix_time, split_hash, split_output_lines
)
# pylint: disable=redefined-outer-name
@pytest.fixture(scope='function')
def stub_engine(tmpdir):
return Engine(template_folder='test', tmp_dir=tmpdir)
def test_byte_number_filter():
assert byte_number_filter(None) == 'not available'
......@@ -43,3 +52,28 @@ def test_split_output_lines():
def test_convert_base64_to_png_filter(tmpdir):
convert_base64_to_png_filter('0000', 'testfile', str(tmpdir))
assert Path(str(tmpdir), 'testfile.png').read_bytes() == b'\xd3\x4d\x34'
def test_filter_latex_special_chars():
assert filter_latex_special_chars('safe') == 'safe'
assert filter_latex_special_chars(r'C:\Windows') == r'C:Windows'
assert filter_latex_special_chars(r'100 $') == r'100 \$'
def test_filter_chars_in_list():
assert filter_chars_in_list([]) == []
assert filter_chars_in_list([r'safe', r'un\safe']) == ['safe', 'unsafe']
def test_render_meta_template(stub_engine):
assert stub_engine.render_meta_template(meta_data='anything') == 'Test anything - '
def test_render_main_template(stub_engine):
assert stub_engine.render_main_template(meta_data='anything', analysis='else') == 'Test anything - else'
def test_render_analysis_template(stub_engine):
assert stub_engine.render_analysis_template(plugin='non_existing', analysis='result') == 'Presenting: result'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment