From eef8041843b919c0bb940695812d20cd8c5bbc54 Mon Sep 17 00:00:00 2001 From: SET Date: Wed, 12 Aug 2020 17:56:14 -0300 Subject: [PATCH] Better test for multiple digikey links --- tests/board_samples/links.sch | 4 ++ tests/test_plot/test_int_bom.py | 69 ++++++++++++++++++- .../int_bom_datasheet_link.kiplot.yaml | 1 + .../int_bom_datasheet_link_xlsx.kiplot.yaml | 1 + .../int_bom_digikey_link.kiplot.yaml | 1 + .../int_bom_digikey_link_xlsx.kiplot.yaml | 3 +- .../int_bom_digikey_links.kiplot.yaml | 21 ++++++ .../int_bom_digikey_links_xlsx.kiplot.yaml | 21 ++++++ 8 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 tests/yaml_samples/int_bom_digikey_links.kiplot.yaml create mode 100644 tests/yaml_samples/int_bom_digikey_links_xlsx.kiplot.yaml diff --git a/tests/board_samples/links.sch b/tests/board_samples/links.sch index eb470a38..d53724fd 100644 --- a/tests/board_samples/links.sch +++ b/tests/board_samples/links.sch @@ -25,6 +25,7 @@ F 2 "" H 2850 2300 50 0001 C CNN F 3 "https://www.molex.com/webdocs/datasheets/pdf/en-us//0022232021_PCB_HEADERS.pdf" H 2850 2300 50 0001 C CNN F 4 "900-0022232021-ND" H 2850 2300 50 0001 C CNN "digikey#" F 5 "0022232021" H 2850 2300 50 0001 C CNN "manf#" +F 6 "WM2700-ND" H 2850 2300 50 0001 C CNN "digikey_alt#" 1 2850 2300 1 0 0 -1 $EndComp @@ -38,6 +39,7 @@ F 2 "" H 4500 2300 50 0001 C CNN F 3 "https://www.molex.com/webdocs/datasheets/pdf/en-us//0022232021_PCB_HEADERS.pdf" H 4500 2300 50 0001 C CNN F 4 "900-0022232021-ND" H 4500 2300 50 0001 C CNN "digikey#" F 5 "0022232021" H 4500 2300 50 0001 C CNN "manf#" +F 6 "WM2700-ND" H 4500 2300 50 0001 C CNN "digikey_alt#" 1 4500 2300 -1 0 0 -1 $EndComp @@ -51,6 +53,7 @@ F 2 "" V 3380 2300 50 0001 C CNN F 3 "https://www.bourns.com/docs/product-datasheets/CRxxxxx.pdf" H 3450 2300 50 0001 C CNN F 4 "CR0805-JW-102ELFCT-ND" V 3450 2300 50 0001 C CNN "digikey#" F 5 "CR0805-JW-102ELF" V 3450 2300 50 0001 C CNN "manf#" +F 6 "CRS0805-JX-102ELFCT-ND" V 3450 2300 50 0001 C CNN "digikey_alt#" 1 3450 2300 0 1 1 0 $EndComp @@ -65,6 +68,7 @@ F 3 "https://content.kemet.com/datasheets/KEM_C1002_X7R_SMD.pdf" H 3750 2500 50 F 4 "399-1147-1-ND" H 3750 2500 50 0001 C CNN "digikey#" F 5 "C0805C102K5RACTU" H 3750 2500 50 0001 C CNN "manf#" F 6 "DNF" H 3750 2500 50 0001 C CNN "Config" +F 7 "399-1149-1-ND" H 3750 2500 50 0001 C CNN "digikey_alt#" 1 3750 2500 1 0 0 -1 $EndComp diff --git a/tests/test_plot/test_int_bom.py b/tests/test_plot/test_int_bom.py index ae7e39c1..58c34367 100644 --- a/tests/test_plot/test_int_bom.py +++ b/tests/test_plot/test_int_bom.py @@ -75,7 +75,7 @@ KIBOM_TEST_COMPONENTS_ALT = ['C1-C4', 'R9-R10', 'R7', 'R8', 'R1-R5'] KIBOM_TEST_COMPONENTS_ALT2 = ['C1-C4', 'R9-R10', 'R7', 'R8', 'R1-R2', 'R4-R5', 'R3'] KIBOM_TEST_EXCLUDE = ['R6'] KIBOM_TEST_GROUPS = 5 -LINK_HEAD = ['References', 'Part', 'Value', 'Quantity Per PCB', 'digikey#', 'manf#'] +LINK_HEAD = ['References', 'Part', 'Value', 'Quantity Per PCB', 'digikey#', 'digikey_alt#','manf#'] LINKS_COMPONENTS = ['J1', 'J2', 'R1'] LINKS_EXCLUDE = ['C1'] LINKS_GROUPS = 2 @@ -326,6 +326,41 @@ def test_int_bom_digikey_link(): ctx.clean_up() +def test_int_bom_digikey_links(): + prj = 'links' + ext = 'html' + ctx = context.TestContextSCH('test_int_bom_digikey_links', prj, 'int_bom_digikey_links', BOM_DIR) + ctx.run() + out = prj + '.' + ext + rows, headers = ctx.load_html(out) + # Test we got the normal and DNF tables + assert len(rows) == 2 + assert len(headers) == 2 + # Test both tables has the same headings and they are the expected + assert headers[0] == headers[1] + assert headers[0] == LINK_HEAD + # Look for reference and quantity columns + ref_column = headers[0].index(REF_COLUMN_NAME) + dk_column = headers[0].index('digikey#') + dk2_column = headers[0].index('digikey_alt#') + # Check the normal table + 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, LINKS_COMPONENTS, LINKS_EXCLUDE) + # Check the digikey link + parts = get_column(rows[0]+rows[1], dk_column, False) + for c in parts: + assert c.strip().startswith('