Added test for "generate_dnf: false" for the XLSX

This commit is contained in:
SET 2020-08-12 14:35:27 -03:00
parent 2196d498ff
commit 56c30f4227
3 changed files with 33 additions and 4 deletions

View File

@ -211,7 +211,7 @@ def test_int_bom_simple_xml():
ctx.clean_up()
def simple_xlsx_verify(ctx, prj):
def simple_xlsx_verify(ctx, prj, dnf=True):
ext = 'xlsx'
ctx.run()
out = prj + '-bom.' + ext
@ -228,10 +228,15 @@ def simple_xlsx_verify(ctx, prj):
qty_column = header.index(QTY_COLUMN_NAME)
check_kibom_test_netlist(rows, ref_column, KIBOM_TEST_GROUPS, KIBOM_TEST_EXCLUDE, KIBOM_TEST_COMPONENTS)
check_dnc(rows, 'R7', ref_column, qty_column)
rows, header, sh_head = ctx.load_xlsx(out, 2)
if dnf:
check_kibom_test_netlist(rows, ref_column, 1, [], KIBOM_TEST_EXCLUDE)
else:
assert rows is None
ctx.clean_up()
def test_int_bom_simple_xlsx():
def test_int_bom_simple_xlsx_1():
prj = 'kibom-test'
ctx = context.TestContextSCH('test_int_bom_simple_xlsx', prj, 'int_bom_simple_xlsx', BOM_DIR)
simple_xlsx_verify(ctx, prj)
@ -776,3 +781,10 @@ def test_int_bom_simple_xlsx_9():
prj = 'kibom-test'
ctx = context.TestContextSCH('test_int_bom_simple_xlsx_9', prj, 'int_bom_simple_xlsx_9', BOM_DIR)
simple_xlsx_verify(ctx, prj)
def test_int_bom_simple_xlsx_a():
""" No DNF """
prj = 'kibom-test'
ctx = context.TestContextSCH('test_int_bom_simple_xlsx_a', prj, 'int_bom_simple_xlsx_a', BOM_DIR)
simple_xlsx_verify(ctx, prj, False)

View File

@ -396,14 +396,16 @@ class TestContext(object):
headers = [k for k in child.attrib.keys()]
return rows, headers
def load_xlsx(self, filename):
def load_xlsx(self, filename, sheet=1):
""" Assumes the components are in sheet1 """
file = self.expect_out_file(os.path.join(self.sub_dir, filename))
subprocess.call(['unzip', file, '-d', self.get_out_path('desc')])
# Some XMLs are stored with 0600 preventing them to be read by next CI/CD stage
subprocess.call(['chmod', '-R', 'og+r', self.get_out_path('desc')])
# Read the table
worksheet = self.get_out_path(os.path.join('desc', 'xl', 'worksheets', 'sheet1.xml'))
worksheet = self.get_out_path(os.path.join('desc', 'xl', 'worksheets', 'sheet'+str(sheet)+'.xml'))
if not os.path.isfile(worksheet):
return None, None, None
rows = []
root = ET.parse(worksheet).getroot()
ns = '{http://schemas.openxmlformats.org/spreadsheetml/2006/main}'

View File

@ -0,0 +1,15 @@
# Example KiPlot config file
kiplot:
version: 1
outputs:
- name: 'bom_internal'
comment: "Bill of Materials in HTML format"
type: bom
dir: BoM
options:
format: XLSX
xlsx:
style: modern-green
generate_dnf: false
col_colors: false