Added test for custom style in HTML.

This commit is contained in:
SET 2020-08-14 13:02:45 -03:00
parent 92e4209ca4
commit a4082e617f
3 changed files with 34 additions and 0 deletions

View File

@ -391,6 +391,16 @@ def test_int_bom_simple_html_8():
logging.debug('Image content OK')
def test_int_bom_simple_html_9():
""" No title, no logo, no info, no stats, custom style """
(rows, headers, sh_head), prj, ctx = simple_html_setup('int_bom_simple_html_9')
style = ctx.load_html_style('kibom-test-bom.html')
with open('tests/data/html_style.css', 'rt') as f:
ref = f.read()
assert style[1:] == ref
simple_html_test(ctx, rows, headers, sh_head, prj, do_title=False, do_logo=False, do_info=False, do_stats=False)
def adapt_xml(h):
h = h.replace(' ', '_')
h = h.replace('"', '')

View File

@ -462,6 +462,14 @@ class TestContext(object):
rows.append(b)
return rows, headers, sh_head
def load_html_style(self, filename):
file = self.expect_out_file(os.path.join(self.sub_dir, filename))
with open(file) as f:
html = f.read()
m = re.search(r'<style>((?:\s+.*?)+)</style>', html, re.MULTILINE)
assert m
return m.group(1)
def load_xml(self, filename):
rows = []
headers = None

View File

@ -0,0 +1,16 @@
# Example KiPlot config file
kiplot:
version: 1
outputs:
- name: 'bom_internal'
comment: "Bill of Materials in HTML format"
type: bom
dir: BoM
options:
html:
logo: false
title: ''
hide_pcb_info: true
hide_stats_info: true
style: tests/data/html_style.css