From 14f2b2b353ee522c84ea72f55ec7ba1821010cbd Mon Sep 17 00:00:00 2001 From: SET Date: Tue, 11 Aug 2020 15:54:02 -0300 Subject: [PATCH] Added test for field collision. --- tests/board_samples/kibom-test-3.sch | 182 +++++++++++++++++++++++++++ tests/test_plot/test_int_bom.py | 23 +++- 2 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 tests/board_samples/kibom-test-3.sch diff --git a/tests/board_samples/kibom-test-3.sch b/tests/board_samples/kibom-test-3.sch new file mode 100644 index 00000000..d0512e3d --- /dev/null +++ b/tests/board_samples/kibom-test-3.sch @@ -0,0 +1,182 @@ +EESchema Schematic File Version 4 +EELAYER 30 0 +EELAYER END +$Descr A4 11693 8268 +encoding utf-8 +Sheet 1 1 +Title "KiBom Test Schematic" +Date "2020-03-12" +Rev "A" +Comp "https://github.com/SchrodingersGat/KiBom" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L Device:R R1 +U 1 1 5E6A2873 +P 2200 2550 +F 0 "R1" V 2280 2550 50 0000 C CNN +F 1 "10K" V 2200 2550 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 2130 2550 50 0001 C CNN +F 3 "~" H 2200 2550 50 0001 C CNN +F 4 "5%" V 2200 2550 50 0001 C CNN "Tolerance" + 1 2200 2550 + 1 0 0 -1 +$EndComp +$Comp +L Device:R R2 +U 1 1 5E6A330D +P 2500 2550 +F 0 "R2" V 2580 2550 50 0000 C CNN +F 1 "10K" V 2500 2550 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 2550 50 0001 C CNN +F 3 "~" H 2500 2550 50 0001 C CNN +F 4 "10%" V 2500 2550 50 0001 C CNN "Tolerance" + 1 2500 2550 + 1 0 0 -1 +$EndComp +$Comp +L Device:R R3 +U 1 1 5E6A35E1 +P 2750 2550 +F 0 "R3" V 2830 2550 50 0000 C CNN +F 1 "10K" V 2750 2550 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 2680 2550 50 0001 C CNN +F 3 "~" H 2750 2550 50 0001 C CNN + 1 2750 2550 + 1 0 0 -1 +$EndComp +$Comp +L Device:R R4 +U 1 1 5E6A37B2 +P 3000 2550 +F 0 "R4" V 3080 2550 50 0000 C CNN +F 1 "10K" V 3000 2550 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 2930 2550 50 0001 C CNN +F 3 "~" H 3000 2550 50 0001 C CNN + 1 3000 2550 + 1 0 0 -1 +$EndComp +$Comp +L Device:R R5 +U 1 1 5E6A39EB +P 3250 2550 +F 0 "R5" V 3330 2550 50 0000 C CNN +F 1 "10K" V 3250 2550 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 3180 2550 50 0001 C CNN +F 3 "~" H 3250 2550 50 0001 C CNN + 1 3250 2550 + 1 0 0 -1 +$EndComp +Text Notes 3500 2550 0 50 ~ 0 +5 x 10K resistors in 0805 package +$Comp +L Device:R R6 +U 1 1 5E6A3CA0 +P 2200 3100 +F 0 "R6" V 2280 3100 50 0000 C CNN +F 1 "4K7" V 2200 3100 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 2130 3100 50 0001 C CNN +F 3 "~" H 2200 3100 50 0001 C CNN +F 4 "DNF" V 2200 3100 50 0001 C CNN "Config" + 1 2200 3100 + 1 0 0 -1 +$EndComp +$Comp +L Device:R R7 +U 1 1 5E6A3F38 +P 2500 3100 +F 0 "R7" V 2580 3100 50 0000 C CNN +F 1 "4700" V 2500 3100 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 3100 50 0001 C CNN +F 3 "~" H 2500 3100 50 0001 C CNN +F 4 "DNC" V 2500 3100 50 0001 C CNN "Config" + 1 2500 3100 + 1 0 0 -1 +$EndComp +$Comp +L Device:R R8 +U 1 1 5E6A4181 +P 2750 3100 +F 0 "R8" V 2830 3100 50 0000 C CNN +F 1 "4.7K" V 2750 3100 50 0000 C CNN +F 2 "Resistor_SMD:R_0805_2012Metric" V 2680 3100 50 0001 C CNN +F 3 "~" H 2750 3100 50 0001 C CNN + 1 2750 3100 + 1 0 0 -1 +$EndComp +Text Notes 3500 3150 0 50 ~ 0 +3 x 4K7 resistors in 0805 package\nNote: Values are identical even if specified differently +$Comp +L Device:R R9 +U 1 1 5E6A448B +P 2200 3650 +F 0 "R9" V 2280 3650 50 0000 C CNN +F 1 "4K7" V 2200 3650 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 2130 3650 50 0001 C CNN +F 3 "~" H 2200 3650 50 0001 C CNN + 1 2200 3650 + 1 0 0 -1 +$EndComp +$Comp +L Device:R R10 +U 1 1 5E6A491A +P 2500 3650 +F 0 "R10" V 2580 3650 50 0000 C CNN +F 1 "4K7" V 2500 3650 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 2430 3650 50 0001 C CNN +F 3 "~" H 2500 3650 50 0001 C CNN + 1 2500 3650 + 1 0 0 -1 +$EndComp +Text Notes 3500 3650 0 50 ~ 0 +3 x 4K7 resistors in 0603 package +Text Notes 550 950 0 50 ~ 0 +This schematic serves as a test-file for the KiBom export script.\n\nAfter making a change to the schematic, remember to re-export the BOM to generate the intermediate .xml file\n\n(The testing framework cannot perform the netlist-export step!) +$Comp +L Device:C C1 +U 1 1 5E6A62CC +P 6650 2550 +F 0 "C1" H 6675 2650 50 0000 L CNN +F 1 "10nF" H 6675 2450 50 0000 L CNN +F 2 "Capacitor_SMD:C_0603_1608Metric" H 6688 2400 50 0001 C CNN +F 3 "~" H 6650 2550 50 0001 C CNN + 1 6650 2550 + 1 0 0 -1 +$EndComp +$Comp +L Device:C C2 +U 1 1 5E6A6854 +P 7050 2550 +F 0 "C2" H 7075 2650 50 0000 L CNN +F 1 "10n" H 7075 2450 50 0000 L CNN +F 2 "Capacitor_SMD:C_0603_1608Metric" H 7088 2400 50 0001 C CNN +F 3 "~" H 7050 2550 50 0001 C CNN + 1 7050 2550 + 1 0 0 -1 +$EndComp +$Comp +L Device:C C3 +U 1 1 5E6A6A34 +P 7450 2550 +F 0 "C3" H 7475 2650 50 0000 L CNN +F 1 "0.01uF" H 7475 2450 50 0000 L CNN +F 2 "Capacitor_SMD:C_0603_1608Metric" H 7488 2400 50 0001 C CNN +F 3 "~" H 7450 2550 50 0001 C CNN + 1 7450 2550 + 1 0 0 -1 +$EndComp +$Comp +L Device:C C4 +U 1 1 5E6A6CB6 +P 7900 2550 +F 0 "C4" H 7925 2650 50 0000 L CNN +F 1 "0.01uf" H 7925 2450 50 0000 L CNN +F 2 "Capacitor_SMD:C_0603_1608Metric" H 7938 2400 50 0001 C CNN +F 3 "~" H 7900 2550 50 0001 C CNN + 1 7900 2550 + 1 0 0 -1 +$EndComp +$EndSCHEMATC diff --git a/tests/test_plot/test_int_bom.py b/tests/test_plot/test_int_bom.py index 9042ace2..b86af664 100644 --- a/tests/test_plot/test_int_bom.py +++ b/tests/test_plot/test_int_bom.py @@ -25,6 +25,8 @@ Tests of Internal BoM files - component_aliases - merge_blank_fields - Don't group components +- Multipart component (not repeated) +- Filed collision Missing: - Variants @@ -63,6 +65,8 @@ COMP_COLUMN_NAME = 'Row' COMP_COLUMN_NAME_R = 'Renglón' KIBOM_TEST_HEAD = [COMP_COLUMN_NAME, 'Description', 'Part', REF_COLUMN_NAME, 'Value', 'Footprint', QTY_COLUMN_NAME, 'Datasheet', 'Config'] +KIBOM_TEST_HEAD_TOL = KIBOM_TEST_HEAD +KIBOM_TEST_HEAD_TOL.insert(-1, 'Tolerance') KIBOM_RENAME_HEAD = [COMP_COLUMN_NAME_R, REF_COLUMN_NAME_R, 'Componente', 'Valor', 'Código Digi-Key', 'Cantidad por PCB'] CONN_HEAD = [COMP_COLUMN_NAME, 'Description', 'Part', REF_COLUMN_NAME, 'Value', 'Footprint', QTY_COLUMN_NAME, 'Datasheet'] KIBOM_TEST_COMPONENTS = ['C1', 'C2', 'C3', 'C4', 'R1', 'R2', 'R3', 'R4', 'R5', 'R7', 'R8', 'R9', 'R10'] @@ -527,7 +531,7 @@ def test_int_bom_no_group_csv(): def test_int_bom_repeat_csv(): - """ Multipart component """ + """ Multipart component (not repeated) """ prj = 'kibom-test-rep' ext = 'csv' ctx = context.TestContextSCH('test_int_bom_repeat_csv', prj, 'int_bom_simple_csv', BOM_DIR) @@ -537,3 +541,20 @@ def test_int_bom_repeat_csv(): assert header == KIBOM_TEST_HEAD check_kibom_test_netlist(rows, header.index(REF_COLUMN_NAME), 1, [], ['U1']) ctx.clean_up() + + +def test_int_bom_collision(): + """ Field collision """ + prj = 'kibom-test-3' + ext = 'csv' + ctx = context.TestContextSCH('test_int_bom_collision', prj, 'int_bom_simple_csv', BOM_DIR) + ctx.run() + out = prj + '-bom.' + ext + rows, header = ctx.load_csv(out) + assert header == KIBOM_TEST_HEAD_TOL + 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.search_err('Field conflict') + ctx.clean_up()