From 56c30f4227518a47f2a23779d53600612404c265 Mon Sep 17 00:00:00 2001 From: SET Date: Wed, 12 Aug 2020 14:35:27 -0300 Subject: [PATCH] Added test for "generate_dnf: false" for the XLSX --- tests/test_plot/test_int_bom.py | 16 ++++++++++++++-- tests/utils/context.py | 6 ++++-- .../int_bom_simple_xlsx_a.kiplot.yaml | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 tests/yaml_samples/int_bom_simple_xlsx_a.kiplot.yaml diff --git a/tests/test_plot/test_int_bom.py b/tests/test_plot/test_int_bom.py index 3928d141..78089fc2 100644 --- a/tests/test_plot/test_int_bom.py +++ b/tests/test_plot/test_int_bom.py @@ -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) diff --git a/tests/utils/context.py b/tests/utils/context.py index 993993bb..217d134e 100644 --- a/tests/utils/context.py +++ b/tests/utils/context.py @@ -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}' diff --git a/tests/yaml_samples/int_bom_simple_xlsx_a.kiplot.yaml b/tests/yaml_samples/int_bom_simple_xlsx_a.kiplot.yaml new file mode 100644 index 00000000..1287318d --- /dev/null +++ b/tests/yaml_samples/int_bom_simple_xlsx_a.kiplot.yaml @@ -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