From c3c86bc4ae36b93a1e2fed812573472944497062 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sat, 1 Aug 2020 15:19:10 -0300 Subject: [PATCH] Added column rename test for the internal BoM. --- tests/test_plot/test_int_bom.py | 30 +++++++++++++++---- .../int_bom_column_rename_csv.kiplot.yaml | 25 ++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 tests/yaml_samples/int_bom_column_rename_csv.kiplot.yaml diff --git a/tests/test_plot/test_int_bom.py b/tests/test_plot/test_int_bom.py index db598eaf..13fcc21a 100644 --- a/tests/test_plot/test_int_bom.py +++ b/tests/test_plot/test_int_bom.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Tests of Internal BoM files @@ -23,14 +24,19 @@ if prev_dir not in sys.path: BOM_DIR = 'BoM' REF_COLUMN_NAME = 'References' +REF_COLUMN_NAME_R = 'Referencias' QTY_COLUMN_NAME = 'Quantity Per PCB' COMP_COLUMN_NAME = 'Component' KIBOM_TEST_HEAD = [COMP_COLUMN_NAME , 'Description', 'Part', REF_COLUMN_NAME, 'Value', 'Footprint', QTY_COLUMN_NAME, 'Datasheet', 'Config'] +KIBOM_RENAME_HEAD = ['Renglón', REF_COLUMN_NAME_R, 'Componente', 'Valor', 'Código Digi-Key', 'Cantidad por PCB'] KIBOM_TEST_COMPONENTS = ['C1', 'C2', 'C3', 'C4', 'R1', 'R2', 'R3', 'R4', 'R5', 'R7', 'R8', 'R9', 'R10'] KIBOM_TEST_COMPONENTS_ALT = ['C1-C4', 'R9-R10', 'R7', 'R8', 'R1-R5'] KIBOM_TEST_EXCLUDE = ['R6'] KIBOM_TEST_GROUPS = 5 +LINKS_COMPONENTS = ['J1', 'J2','R1'] +LINKS_EXCLUDE = ['C1'] +LINKS_GROUPS = 2 def check_kibom_test_netlist(rows, ref_column, groups, exclude, comps): @@ -192,9 +198,9 @@ def test_int_bom_datasheet_link(): ref_column = headers[0].index(REF_COLUMN_NAME) part_column = headers[0].index('Part') # Check the normal table - check_kibom_test_netlist(rows[0], ref_column, 2, ['C1'], ['J1', 'J2','R1']) + check_kibom_test_netlist(rows[0], ref_column, LINKS_GROUPS, LINKS_EXCLUDE, LINKS_COMPONENTS) # Check the DNF table - check_kibom_test_netlist(rows[1], ref_column, 1, ['J1', 'J2','R1'], ['C1']) + check_kibom_test_netlist(rows[1], ref_column, 1, LINKS_COMPONENTS, LINKS_EXCLUDE) # Check the datasheet link parts = get_column(rows[0]+rows[1], part_column, False) for c in parts: @@ -222,9 +228,9 @@ def test_int_bom_digikey_link(): ref_column = headers[0].index(REF_COLUMN_NAME) dk_column = headers[0].index('digikey#') # Check the normal table - check_kibom_test_netlist(rows[0], ref_column, 2, ['C1'], ['J1', 'J2','R1']) + check_kibom_test_netlist(rows[0], ref_column, LINKS_GROUPS, LINKS_EXCLUDE, LINKS_COMPONENTS) # Check the DNF table - check_kibom_test_netlist(rows[1], ref_column, 1, ['J1', 'J2','R1'], ['C1']) + check_kibom_test_netlist(rows[1], ref_column, 1, LINKS_COMPONENTS, LINKS_EXCLUDE) # Check the digikey link parts = get_column(rows[0]+rows[1], dk_column, False) for c in parts: @@ -245,7 +251,7 @@ def test_int_bom_join_1(): ref_column = header.index(REF_COLUMN_NAME) manf_column = header.index('manf') value_column = header.index('Value') - check_kibom_test_netlist(rows, ref_column, 3, [], ['C1', 'J1', 'J2', 'R1']) + check_kibom_test_netlist(rows, ref_column, LINKS_GROUPS+1, [], LINKS_EXCLUDE+LINKS_COMPONENTS) assert rows[0][ref_column] == 'C1' assert rows[0][value_column] == '1nF 10% 50V' assert rows[0][manf_column] == 'KEMET C0805C102K5RACTU' @@ -315,6 +321,7 @@ def test_int_bom_use_alt(): def test_int_bom_no_number_rows(): + """ number_rows: false """ prj = 'kibom-test' ext = 'csv' ctx = context.TestContextSCH('test_int_bom_no_number_rows', prj, 'int_bom_no_number_rows', BOM_DIR) @@ -327,3 +334,16 @@ def test_int_bom_no_number_rows(): 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_column_rename_csv(): + prj = 'links' + ext = 'csv' + ctx = context.TestContextSCH('test_int_bom_column_rename_csv', prj, 'int_bom_column_rename_csv', BOM_DIR) + ctx.run() + out = prj + '-bom.' + ext + rows, header = ctx.load_csv(out) + assert header == KIBOM_RENAME_HEAD + ref_column = header.index(REF_COLUMN_NAME_R) + check_kibom_test_netlist(rows, ref_column, LINKS_GROUPS, LINKS_EXCLUDE, LINKS_COMPONENTS) + ctx.clean_up() diff --git a/tests/yaml_samples/int_bom_column_rename_csv.kiplot.yaml b/tests/yaml_samples/int_bom_column_rename_csv.kiplot.yaml new file mode 100644 index 00000000..7ba74246 --- /dev/null +++ b/tests/yaml_samples/int_bom_column_rename_csv.kiplot.yaml @@ -0,0 +1,25 @@ +# Example KiPlot config file +kiplot: + version: 1 + +outputs: + - name: 'bom_internal' + comment: "Bill of Materials in CSV format" + type: bom + dir: BoM + options: + format: CSV + columns: + - field: Component + name: Renglón + - field: References + name: Referencias + - field: Part + name: Componente + - field: Value + name: Valor + - field: digikey# + name: Código Digi-Key + - field: Quantity Per PCB + name: Cantidad por PCB +