From 92cdf49c2daa9897909b5b30d80300b3c7de79db Mon Sep 17 00:00:00 2001 From: SET Date: Wed, 12 Aug 2020 13:03:08 -0300 Subject: [PATCH] Added XLSX tests for style variations. Just tested they are accepted, not correctness. --- tests/test_plot/test_int_bom.py | 50 +++++++++++-------- .../int_bom_simple_xlsx_7.kiplot.yaml | 15 ++++++ .../int_bom_simple_xlsx_8.kiplot.yaml | 13 +++++ .../int_bom_simple_xlsx_9.kiplot.yaml | 13 +++++ 4 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 tests/yaml_samples/int_bom_simple_xlsx_7.kiplot.yaml create mode 100644 tests/yaml_samples/int_bom_simple_xlsx_8.kiplot.yaml create mode 100644 tests/yaml_samples/int_bom_simple_xlsx_9.kiplot.yaml diff --git a/tests/test_plot/test_int_bom.py b/tests/test_plot/test_int_bom.py index 21a9ab57..ac653e07 100644 --- a/tests/test_plot/test_int_bom.py +++ b/tests/test_plot/test_int_bom.py @@ -37,6 +37,7 @@ Missing: - various boards - stats info - datasheet and digikey for XLSX +- XLSX colors For debug information use: pytest-3 --log-cli-level debug @@ -209,10 +210,8 @@ def test_int_bom_simple_xml(): ctx.clean_up() -def test_int_bom_simple_xlsx(): - prj = 'kibom-test' +def simple_xlsx_verify(ctx, prj): ext = 'xlsx' - ctx = context.TestContextSCH('test_int_bom_simple_xlsx', prj, 'int_bom_simple_xlsx', BOM_DIR) ctx.run() out = prj + '-bom.' + ext rows, header, sh_head = ctx.load_xlsx(out) @@ -231,6 +230,12 @@ def test_int_bom_simple_xlsx(): ctx.clean_up() +def test_int_bom_simple_xlsx(): + prj = 'kibom-test' + ctx = context.TestContextSCH('test_int_bom_simple_xlsx', prj, 'int_bom_simple_xlsx', BOM_DIR) + simple_xlsx_verify(ctx, prj) + + def get_column(rows, col, split=True): components = [] for r in rows: @@ -682,24 +687,8 @@ def test_int_bom_simple_xlsx_2(): def test_int_bom_simple_xlsx_3(): """ No logo """ prj = 'kibom-test' - ext = 'xlsx' ctx = context.TestContextSCH('test_int_bom_simple_xlsx_3', prj, 'int_bom_simple_xlsx_3', BOM_DIR) - ctx.run() - out = prj + '-bom.' + ext - rows, header, sh_head = ctx.load_xlsx(out) - check_head_xlsx(sh_head, - [prj, 'default', 'A', '2020-03-12', None], - [KIBOM_TEST_GROUPS+len(KIBOM_TEST_EXCLUDE), - len(KIBOM_TEST_COMPONENTS)+len(KIBOM_TEST_EXCLUDE), - len(KIBOM_TEST_COMPONENTS), - 1, - len(KIBOM_TEST_COMPONENTS)]) - assert header == KIBOM_TEST_HEAD - ref_column = header.index(REF_COLUMN_NAME) - 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) - ctx.clean_up() + simple_xlsx_verify(ctx, prj) def test_int_bom_simple_xlsx_4(): @@ -765,3 +754,24 @@ def test_int_bom_simple_xlsx_6(): check_kibom_test_netlist(rows, ref_column, KIBOM_TEST_GROUPS, KIBOM_TEST_EXCLUDE, KIBOM_TEST_COMPONENTS) check_dnc(rows, 'R7', ref_column, qty_column) ctx.clean_up() + + +def test_int_bom_simple_xlsx_7(): + """ Logo from file, no colors (no real test for the style) """ + prj = 'kibom-test' + ctx = context.TestContextSCH('test_int_bom_simple_xlsx_7', prj, 'int_bom_simple_xlsx_7', BOM_DIR) + simple_xlsx_verify(ctx, prj) + + +def test_int_bom_simple_xlsx_8(): + """ Style green (no real test for the style) """ + prj = 'kibom-test' + ctx = context.TestContextSCH('test_int_bom_simple_xlsx_8', prj, 'int_bom_simple_xlsx_8', BOM_DIR) + simple_xlsx_verify(ctx, prj) + + +def test_int_bom_simple_xlsx_9(): + """ Style red (no real test for the style) """ + 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) diff --git a/tests/yaml_samples/int_bom_simple_xlsx_7.kiplot.yaml b/tests/yaml_samples/int_bom_simple_xlsx_7.kiplot.yaml new file mode 100644 index 00000000..4263477a --- /dev/null +++ b/tests/yaml_samples/int_bom_simple_xlsx_7.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: + logo: docs/images/bot.png + col_colors: false + diff --git a/tests/yaml_samples/int_bom_simple_xlsx_8.kiplot.yaml b/tests/yaml_samples/int_bom_simple_xlsx_8.kiplot.yaml new file mode 100644 index 00000000..9154643a --- /dev/null +++ b/tests/yaml_samples/int_bom_simple_xlsx_8.kiplot.yaml @@ -0,0 +1,13 @@ +# 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 diff --git a/tests/yaml_samples/int_bom_simple_xlsx_9.kiplot.yaml b/tests/yaml_samples/int_bom_simple_xlsx_9.kiplot.yaml new file mode 100644 index 00000000..a31e84cc --- /dev/null +++ b/tests/yaml_samples/int_bom_simple_xlsx_9.kiplot.yaml @@ -0,0 +1,13 @@ +# 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-red